Could not install packages due to an EnvironmentEr

2020-02-04 21:01发布

问题:

I relatively new to coding so I am not (yet) running virtual environments. Rather, I am just downloading packages with pip straight to my pc to run python 3.7 in atom.

When I tried to use pip the other day to install the scrapy package like so -m pip install --user scrapy

I got this error: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\users\\adrian\\appdata\\roaming\\python\\python37\\site-packages\\pip-19.0.1.dist-info\\METADATA'

Most of the other answers I have seen on related errors had people use conda to install some type of fix I think? When I tried to use conda to execute one of the fixes I recieved a CondaHTTPError: SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/noarch/repodata.json.bz2 (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available.

Any direction would be heartily appreciated :-)

回答1:

TL;DR:

Problem: Long install path

Solution: Install the desired python package (in my case tensorflow) in the folder which has a shorter path (for example C:/my_py_packages/some_package) or set the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1 as mentioned here.

Original answer: I got here by having this kind of error when I tried installing tensorflow library. My error was the following:

Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\moj ifajlovi\faks\11master\1semestar\siap-sistemizaistrazivanjeianalizupodataka_(datamining)\projek at\rad\venvs\siap_venv\Lib\site-packages\tensorflow_estimator\python\estimator\canned\line ar_optimizer\python\utils\__pycache__\sharded_mutable_dense_hashtable.cpython-37.pyc'

So, there was no sharded_mutable_dense_hashtable.cpython-37.pyc file in the __pycache__ directory. But, sharded_mutable_dense_hashtable.cpython-37.pyc file was in the utils directory (which is the parent directory of __pycache__ directory).

That's why I tried manually copying the sharded_mutable_dense_hashtable.cpython-37.pyc file in the __pycache__ directory. When I tried that, I had a copy error which stated that the path was too long, so it couldn't put the file in the directory.

So, the solution:

Install the desired python package (in my case tensorflow) in the folder which has a shorter path (for example C:/my_py_packages/some_package) or set the registry value HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem@LongPathsEnabled to 1 as mentioned here.



回答2:

I had the same error trying to install Jupyter, with the path under my user profile ending with \site-packages\pip-19.0.1.dist-info\METADATA

When I checked that location it didnt contain METADATA, but another folder named pip-19.0.1.dist-info That folder had several files in it including METADATA

I moved those files back the directory so it matched the path listed in the error and then upgraded pip (Under an administrator account)

pip3 install --upgrade pip

Which worked and updated pip

I could then run the Jupyter install and got no error



回答3:

So the above so called solution didn't make much sense to me.. Sorter path?? Anyways, what worked for me, is this.

My error:

Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'c:\\users\\MYUSERNAME\\appdata\\roaming\\python\\python37\\site-packages\\pip-19.0.1.dist-info\\METADATA'

So I went to the directory:

c:\\users\\MYUSERNAME\\appdata\\roaming\\python\\python37\\site-packages\\pip-19.0.1.dist-info\\   

Indeed there was no MetaData file. However there was a folder called 19.0.1.dist-info, inside that, has the meta data file. Just move it outside into the above directory, and BAM! Problem fixed.



回答4:

You might not like this answer, but what worked for me was to find the file: "METADATA" from a folder with an older version and copy it into the newer one. This is not a solution I'm confident in, but pip at least finished installing.



回答5:

I experienced this error while I was installing Apache Superset on Windows 10. The problem is with the MAX_PATH length.

pip on windows is not able to handle those long installation path url so it usually results in errors.

Solution: What worked for me was to Uninstall python then ReInstalled it again but this time after a successful reinstallation, you HAVE TO DISABLE THE PATH LENGTH LIMIT



标签: python pip conda