J__1
J__1

Reputation: 441

Python: Could not install packages due to an OSError: [Errno 2] No such file or directory

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'**.

Upvotes: 34

Views: 363055

Answers (15)

phancuongviet
phancuongviet

Reputation: 435

My solution related to pip version error,

  1. Running pip upgrade command
  2. Exit commandline
  3. Retry run pip install <your_framwork_or_lib>

Hope to help you!

Upvotes: 0

yahia hisham
yahia hisham

Reputation: 1

I had the same problem to solve it was pretty easy at first run PowerShell in the administrator mode then type in this command New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" ` -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force then restart your PC and run your pip install command and everything should work Note: I got this info from "https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell#enable-long-paths-in-windows-10-version-1607-and-later" for more info visit the website.

Upvotes: 0

Georgegoldman
Georgegoldman

Reputation: 173

So i deleted my venv, restarted my machine, then i created a new venv, finally everything works fine.

Upvotes: 0

zimeg
zimeg

Reputation: 478

This same error can also happen when using a requirements.txt if the file isn't formatted correctly, with an output that might resemble:

$ pip install -r requirements.txt
Processing /private/tmp/pygments-20230806-6216-4zajry/Pygments-2.16.1 (from -r requirements.txt (line 2))
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/private/tmp/pygments-20230806-6216-4zajry/Pygments-2.16.1'

Recreating this file with pip freeze > requirements.txt fixed this for me!

Upvotes: 0

You can resolve this issue by enabling Windows Long Paths support by following these steps:

Open the Group Policy Editor by running gpedit.msc in the command prompt. Go to Computer Configuration > Administrative Templates > System > Filesystem. Find the Enable Win32 long paths policy and enable it.

Upvotes: 0

E.T. HanZ
E.T. HanZ

Reputation: 9

This is how I fixed similar issue when I installed tensorflow:

  1. On your search box, Search for: "Registry Editor"
  2. Open this path"Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem"
  1. Looking for this file: change the value from 0 to 1
  1. then restart your computer

Further study: "https://www.howtogeek.com/266621/how-to-make-windows-10-accept-file-paths-over-260-characters/#:~:text=In%20Windows%2010%20Pro%20or%20Enterprise%2C%20hit%20Start%2C,%E2%80%9CEnable%20win32%20long%20paths%E2%80%9D%20item%20and%20double-click%20it."

Upvotes: 1

Lasitha Yapa
Lasitha Yapa

Reputation: 4609

For me issue was with the long paths support for Windows. And here they suggest the solution and worked fine for me.

Windows Fix Maximum Path Length Limitation

From the above source this is the final solution

The registry key Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled (Type: REG_DWORD) must exist and be set to 1

Upvotes: 2

VithurabimanS
VithurabimanS

Reputation: 1

The steps here fixed it https://www.youtube.com/watch?v=rKYRcwbFp6Y . The step is basically to change the include-system-site-packages to true in pyvenv.cfg file in your virtual env folder

Upvotes: -3

傅益娴
傅益娴

Reputation: 11

keep package up to date.I upgarde my pip and the problem is gone.

Upvotes: 1

vineetma
vineetma

Reputation: 400

Fixed by doing

conda install google-pasta

this directory under envs/xxxx/Lib/site-packages/ was not having METADATA. Likely to be partial installation.

Upvotes: 2

Vidura Karunarathna
Vidura Karunarathna

Reputation: 421

Run CMD in administrator mode and enter:

pip install sklearn --user

and Done!!

Upvotes: 36

Tony Gilman
Tony Gilman

Reputation: 1

If Windows is 8.
You need to change your access policy inside Python3 repository where all packages, including PIP.

"Properties" -> "Security" -> select a user -> select "Change" and everything below.
Next, update PIP (py -m pip install --upgrade pip) and install the packages inside ENV

Upvotes: 0

Elaine
Elaine

Reputation: 403

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.

Upvotes: 4

Gianmarco G
Gianmarco G

Reputation: 381

Try sudo pip install 'package name' --user

Upvotes: 10

Kerryn
Kerryn

Reputation: 301

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/

Upvotes: 30

Related Questions