scikit-learn: Could not install packages due to an OSError
Describe the bug
When trying to install scikit-learn
, I get the following error:
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\Users\\movgp\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\sklearn\\datasets\\tests\\data\\openml\\292\\api-v1-json-data-list-data_name-australian-limit-2-data_version-1-status-deactivated.json.gz'
After enabling long-path name support in the group policies, I get the following error:
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Users\\movgp\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages\\sklearn\\.libs\\vcomp140.dll'
Check the permissions.
After also running pip with admin rights, I get the following output:
Collecting scikit-learn
Using cached scikit_learn-0.24.1-cp39-cp39-win_amd64.whl (6.9 MB)
Requirement already satisfied: scipy>=0.19.1 in c:\users\movgp\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from scikit-learn) (1.6.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in c:\users\movgp\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from scikit-learn) (2.1.0)
Requirement already satisfied: numpy>=1.13.3 in c:\users\movgp\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from scikit-learn) (1.19.5)
Requirement already satisfied: joblib>=0.11 in c:\users\movgp\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from scikit-learn) (1.0.0)
Installing collected packages: scikit-learn
Successfully installed scikit-learn-0.24.1
Steps/Code to Reproduce
- Use Windows 10
- Install Python (3.8 or 3.9) from Windows Store
- Install Visual Studio Code
- Install Python and Jupyter Plugins into Visual Studio Code
- Create a new Jupyter Notebook
- Install Jupyter Server when VS Code asks to do so
- Execute
import sys
!{sys.executable} -m pip install scikit-learn
Expected Results
sci-learn
package should install without error.- there should be no need for enabling long paths
- there should be no requirement for admin rights
If those issues can’t be (easily) fixed, it needs to be documented in the install instructions.
Actual Results
- user needs to enable long path names (in group policy editor or system registry)
- user needs to run python with admin rights
- steps are not documented
Versions
Windows-10-10.0.19041-SP0
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)]
NumPy 1.19.5
SciPy 1.6.0
Scikit-Learn 0.24.1
Imbalanced-Learn 0.7.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 18 (6 by maintainers)
Try
and Done!!
Hey, i had an similar error. For me was removing the 260 character path limit the solution. https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/
@cmarmo this is not about the permission issue, but missing precondition checks in the setup. The installer should output an helpful error instead of failing and letting the user figure out what went wrong.
@lesteve , as a side note this is a known and documented issue.
My semi-random guesses:
pytest --pyargs
).pip
command was executed. In my experience, Windows has a habit of locking files (even more so .dll files) which is very annoying. When I was working on Windows (a while ago now) ProcesExplorer was quite useful to figure out which process was locking a particular file.