【问题标题】:setuptools is installed but I can't import itsetuptools 已安装,但我无法导入它
【发布时间】:2019-06-14 08:29:56
【问题描述】:

尝试使用pip安装:

user@Ubuntu ~/ $ sudo pip --no-cache-dir install --user -U setuptools
Requirement already up-to-date: setuptools in /home/coder/.local/lib/python3.5/site-packages (40.6.3)

但是当我想import它时,它就不再导入了。

user@Ubuntu ~/ $ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named setuptools
>>>

【问题讨论】:

标签: python python-2.7


【解决方案1】:

我从这里的这个链接得到了解决方案 Correct command for pip upgrade我的解决方案如下:

User@Ubuntu ~/Documents/RE $ sudo python -m pip install --upgrade pip setuptools wheel

Requirement already up-to-date: pip in /home/coder/.local/lib/python2.7/site-packages (18.1)
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/37/06/754589caf971b0d2d48f151c2586f62902d93dc908e2fd9b9b9f6aa3c9dd/setuptools-40.6.3-py2.py3-none-any.whl (573kB)
    100% |████████████████████████████████| 573kB 666kB/s 
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/ff/47/1dfa4795e24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-none-any.whl
Installing collected packages: setuptools, wheel
Successfully installed setuptools-40.6.3 wheel-0.32.3

user@Ubuntu ~/Documents/RE $ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import setuptools
>>> 

所以正确的命令是这样的:

user@ubuntu ~/Documents/RE $ sudo python -m pip install --upgrade pip setuptools wheel

【讨论】:

    猜你喜欢
    • 2015-08-13
    • 2023-03-08
    • 1970-01-01
    • 2020-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    • 1970-01-01
    相关资源
    最近更新 更多