Python: Could not install packages due to an OSError: [Errno 2] No such file or directory
Solution 1
I had exactly the same issue installing this package on my Windows laptop - then read of the 260 character limit. I followed this guide - and after rebooting, successfully installed 'sklearn':
https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/
Solution 2
Try sudo pip install
'package name' --user
Solution 3
Run CMD in administrator mode and enter:
pip install sklearn --user
and Done!!
Solution 4
I removed and reinstalled Python and then entered this into my terminal command line:
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip install --upgrade pip
and it fixed my issue.
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip install
and it should work.
Related videos on Youtube

J__1
Updated on August 21, 2022Comments
-
J__1 9 months
I try to use pip to install
sklearn
, and I receive the following error message:ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\Users\13434\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\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'**.
Can anyone help? Thanks.
-
Yash Gupta about 2 yearsNow Package is installed but while importing the package I am getting error.
-
Anirudh Ajith almost 2 yearsThanks a lot! But why would anyone restrict path lengths by default? Silly Windows :P
-
ablmmcu over 1 yearThis method also giving an error in venv.
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
-
Gianmarco G over 1 yearGo to the
pyvenv.cfg
file in your Virtual environment folder and setinclude-system-site-packages = true
and save the changes. Afterwards reactivate the virtual environment. Otherwise, try the command I gave without--user
This may also work -
sanjay over 1 yearYes pip install flask-restful --user Its worked... thanks