我对python的安装路径和配置感到困惑。
我知道pip这个命令用于安装或列出模块。
示例与pip freeze
类似。它将显示模块列表。
最近,我执行pip时遇到错误。我在系统上没有任何virtualenv的python2和python3。我使用ls /usr/bin/python* -al | awk {print $9 $10 $11}
来了解python命令,使用ls /usr/bin/pip* -al
来了解pip命令。
python->python2.7
python2->python2.7
python2.7
python2.7-config->arm-linux-gnueabihf-python2.7-config
python2-config->python2.7-config
python3->python3.4
python3.4
python3.4m
python3m->python3.4m
python-config->python2.7-config
pip pip2 pip3
此外,我在ls
上使用/usr/local/bin
并知道pip命令。
pip pip2 pip2.7 pip3 pip3.4 pip3.5
执行pip时出现错误信息。
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 572, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2752, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2405, in load
return self.resolve()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2411, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 76, in <module>
from pip.commands import commands, get_summaries, get_similar_commands
File "/usr/local/lib/python2.7/dist-packages/pip/commands/__init__.py", line 6, in <module>
from pip.commands.bundle import BundleCommand
File "/usr/local/lib/python2.7/dist-packages/pip/commands/bundle.py", line 6, in <module>
from pip.commands.install import InstallCommand
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 5, in <module>
from pip.req import InstallRequirement, RequirementSet, parse_requirements
File "/usr/local/lib/python2.7/dist-packages/pip/req/__init__.py", line 3, in <module>
from .req_install import InstallRequirement
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 42, in <module>
from pip.utils.hashes import Hashes
File "/usr/local/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`
如何解决此错误?为什么系统会显示错误?
答案 0 :(得分:0)
结果是没有特定命令的冲突。
使用python2.7 -m pip
或python2 -m pip
作为特定命令。反之亦然,在python3上,使用python3 -m pip
或python3.4 -m pip
作为特定命令。
此外,使用python或python3进入交互模式。然后,使用import sys
和sys.path
来获取python包的路径。