Pip cannot find metadata file - EnvironmentError

后端 未结 6 1967
感情败类
感情败类 2020-12-11 18:59

Whenever I run pip to install the Flask packages like virtualenv in Ubuntu 16.04, I get this error:

pip install virtualenv

相关标签:
6条回答
  • 2020-12-11 19:28

    conda install -c conda-forge requests solved my problem. Of course, you need to reinstall the package that is problematic for you. Using pip to reinstall it did not work for me.

    0 讨论(0)
  • 2020-12-11 19:31

    I just ran into this with a different package, using Python 3.6.5 and pip 19.2.3. I was hesitant to use the solutions here (and on similar SO questions) so I just tried the following and it cleared up the issue:

    pip install --force-reinstall package_with_metadata_issue

    Note that my case was complaining about the black package, which was a dependency of something else I was trying to install (with a simple pip install other_package). Black had already been installed and working on my system for a while, so it's unclear how it got into a bad state or what changed in pip such that it couldn't handle the package's state.

    To be specific, the OP could try:

    pip install --force-reinstall virtualenv

    Though it seems like many other people here had an issue with pip itself, so that may just be kicking the can down the road until pip is in a good state.

    0 讨论(0)
  • 2020-12-11 19:32

    I got same error

    Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/vagrant/.local/lib/python3.7/site-packages/pip-18.1.dist-info/RECORD'
    

    It seems that there is a conflict between /usr/bin/pip and /home/vagrant/.local/lib/python3.7/.

    My solution is avoiding the error.

    • pip freeze > requirements.txt
    • I deleted the /home/user/.local/lib/python3.7 dir
    • sudo pip install --upgrade pip
    • pip install -r requirements.txt --user
    • fixed it
    0 讨论(0)
  • 2020-12-11 19:35

    I think the root of your error is that your pip is configured to work with Python3.5 (and looks in its specific Pythonpath for the metadata), while your Python version is 3.6.8

    Virtual environments in Python 3 have been made simpler, in my opinion, with the usage of the built-in venv. Also, your Python and Flask versions should coincide, which is here, not the case.

    I'd suggest you take the following steps

    • Create a new virtual environment using

    python3 -m venv /path/to/new/virtual/environment

    • Activate the virtual environment by
    cd /path/to/new/virtual/environment
    source env/bin/activate
    

    You now have an isolated, clean-slate environment, where you only have a single version of Python.

    • Run pip install --upgrade pip to upgrade the virtual environment pip to the version that is compatible with your Python version.

    • Run pip install flask, and install your whole stack from scratch, so that the libraries and Python executable versions are aligned.

    0 讨论(0)
  • 2020-12-11 19:40

    I encountered the same problem recently.

    Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '~/.local/lib/python3.7/site-packages/pip-19.0.1.dist-info/METADATA'
    

    In the folder

    ~/.local/lib/python3.7/site-packages/pip-19.0.1.dist-info/
    

    I found another one named pip-19.0.1.dist-info, and the last one contained all the required files for the pip.

    I just used

    cd ~/.local/lib/python3.7/site-packages/pip-19.0.1.dist-info/
    cp -r ./pip-19.0.1.dist-info/* ./
    rm -r ./pip-19.0.1.dist-info
    

    Obviously that you need to replace python version with your own and also check if files

    entry_points.txt  INSTALLER  LICENSE.txt  METADATA  RECORD  top_level.txt  WHEEL
    

    are in here.

    Maybe it will help you, luck.

    0 讨论(0)
  • 2020-12-11 19:45

    I meet the same problem

    ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/root/anaconda3/lib/python3.6/site-packages/tornado-6.0.4.dist-info/METADATA
    

    then I cd /root/anaconda3/lib/python3.6/site-packages/tornado-6.0.4.dist-info/ && ls

    DESCRIPTION.rst  LICENSE.txt  metadata.json
    

    finally, I did cp metadata.json METADATA solved the problem. maybe this is helpful to you.

    0 讨论(0)
提交回复
热议问题