python - 为什么 pip 说 "No module named commands.install"?

标签 python windows installation pygame pip

我已经安装了 pip,并且我已经将我在 cmd 中的目录移动到 C:\Python27\Scripts。我试试这段代码: 'pip install whatever.whl'


它在随机代码的底部说(看起来像 python):


'ImportError: 没有名为 commands.install 的模块' 发生了什么事?

最佳答案

我在另一种情况下通过卸载有问题的软件包解决了这个问题。你可以试试:

sudo pip install -U setuptools

这是我的日志:

sam@sam:~$ sudo pip install protobuf --upgrade
The directory '/home/sam/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/sam/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting protobuf
  Downloading protobuf-2.6.1.tar.gz (188kB)
    100% |████████████████████████████████| 188kB 194kB/s 
Collecting setuptools (from protobuf)
  Downloading setuptools-18.5-py2.py3-none-any.whl (462kB)
    100% |████████████████████████████████| 462kB 940kB/s 
Installing collected packages: setuptools, protobuf
  Found existing installation: setuptools 18.4
    Uninstalling setuptools-18.4:
      Successfully uninstalled setuptools-18.4
  Rolling back uninstall of setuptools
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 311, in run
    root=options.root_path,
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 646, in install
    **kwargs
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 803, in install
    self.move_wheel_files(self.source_dir, root=root)
  File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 998, in move_wheel_files
    isolated=self.isolated,
  File "/usr/local/lib/python2.7/dist-packages/pip/wheel.py", line 242, in move_wheel_files
    name, user=user, home=home, root=root, isolated=isolated
  File "/usr/local/lib/python2.7/dist-packages/pip/locations.py", line 183, in distutils_scheme
    i = d.get_command_obj('install', create=True)
  File "/usr/lib/python2.7/distutils/dist.py", line 845, in get_command_obj
    klass = self.get_command_class(command)
  File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 430, in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2355, in load
    return self.resolve()
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2361, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named command.install
sam@sam:~$

sam@sam:~$ sudo pip install -U setuptools
The directory '/home/sam/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/sam/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting setuptools
  Downloading setuptools-18.5-py2.py3-none-any.whl (462kB)
    100% |████████████████████████████████| 462kB 1.3MB/s 
Installing collected packages: setuptools
  Found existing installation: setuptools 18.4
    Uninstalling setuptools-18.4:
      Successfully uninstalled setuptools-18.4
Successfully installed setuptools-18.5
sam@sam:~$ 
sam@sam:~$ sudo pip install protobuf --upgrade
The directory '/home/sam/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/sam/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting protobuf
  Downloading protobuf-2.6.1.tar.gz (188kB)
    100% |████████████████████████████████| 188kB 214kB/s 
Requirement already up-to-date: setuptools in /usr/local/lib/python2.7/dist-packages (from protobuf)
Installing collected packages: protobuf
  Found existing installation: protobuf 2.4.1
    Uninstalling protobuf-2.4.1:
      Successfully uninstalled protobuf-2.4.1
  Running setup.py install for protobuf
Successfully installed protobuf-2.6.1
sam@sam:~$ 

关于python - 为什么 pip 说 "No module named commands.install"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28196645/

相关文章:

python - 找出网格中的最大颜色数

python - Pandas 找到 df1 中 df2 与任一列匹配的每一行

python - @property 是否是一种访问类内私有(private)和 protected 成员的方法?

java - windows下运行hadoop作业

Python easy_install 抛出 chmod 错误

python - 焦糖 : 'pyrouge_set_rouge_path' is not recognized as an internal or external command

python - 如何判断 Python 程序在运行时启用了哪些来自 '__future__' 的编译指示?

Windows 命令行字符串替换删除 "!"

python - 初学者安装 nosetests 包

Java:替换窗口左上角的咖啡杯图标