在尝试安装pip
时,virtualenv
发生以下错误。
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 63, in <module>
from pip.commands import commands, get_summaries, get_similar_commands
File "/usr/lib/python2.7/dist-packages/pip/commands/__init__.py", line 6, in <module>
from pip.commands.bundle import BundleCommand
File "/usr/lib/python2.7/dist-packages/pip/commands/bundle.py", line 6, in <module>
from pip.commands.install import InstallCommand
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 5, in <module>
from pip.req import InstallRequirement, RequirementSet, parse_requirements
File "/usr/lib/python2.7/dist-packages/pip/req/__init__.py", line 3, in <module>
from .req_install import InstallRequirement
File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 42, in <module>
from pip.utils.hashes import Hashes
File "/usr/lib/python2.7/dist-packages/pip/utils/hashes.py", line 5, in <module>
from pip.exceptions import HashMismatch, HashMissing, InstallationError
ImportError: cannot import name HashMissing
我怎样才能解决Hashmissing
错误?通过HTTPSHandler link尝试。
我有类似的问题。在我的情况下,它是在系统升级和“修复”virtualenv
根据https://www.guyrutenberg.com/2012/05/30/fixing-virtualenv-after-upgrading-your-distributionpython/,即。再次运行virtualenv
。正如我现在看到的那样,它通过覆盖一些文件并创建一个破碎的混乱来合并两个版本的pip
和setuptools
。我的解决方案是从pip
的setuptools
手动删除virtualenv
和site-packages
,然后运行virtualenv
进行修复。
VENV_DIR="<your venv dir>"
rm -r "$VENV_DIR"/lib/python2.7/site-packages/{pip,setuptools} "$VENV_DIR"/lib/python2.7/site-packages/setuptools-* "$VENV_DIR"/lib/python2.7/site-packages/pip-*
virtualenv "$VENV_DIR"
source "$VENV_DIR"/bin/activate
pip install -U pip setuptools
在你的情况下它不是virtualenv
,但我认为原因是相似的(两个pip
版本一个在另一个)。
下面的答案是好的,有一个修复 - 必须使用pip2:
VENV_DIR="<your venv dir>"
rm -r "$VENV_DIR"/lib/python2.7/site-packages/{pip,setuptools} "$VENV_DIR"/lib/python2.7/site-packages/setuptools-* "$VENV_DIR"/lib/python2.7/site-packages/pip-*
virtualenv "$VENV_DIR"
source "$VENV_DIR"/bin/activate
pip2 install -U pip setuptools
在Python 2.7中没有这样的类'HashMissing',所以你得到这个错误。
为什么不只是import pip.exceptions
'原样'?