python - setuptools 已安装,但我无法导入它
问题描述
尝试安装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
>>>
解决方案
我从这里的这个链接得到了解决方案 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
推荐阅读
- node.js - Angular + Electron - 找不到模块 main.js
- javascript - 表单输入元素与反应页面的 URL 混淆
- javascript - 使用 html css javascript & Jquery 聊天机器人应用程序中的语音气泡
- python - 两个函数之间的全局变量的范围是什么
- javascript - 如何从 Google Sheet 中的列值分配对象?
- python - 有没有办法从单个 xlsx 读取多个 excel 选项卡/工作表到多个数据框,每个数据框都以工作表名称命名?
- java - Android与纯Java的不同加密 - RSA/ECB/OAEPWithMD5AndMGF1Padding
- vue.js - 使用 vue.js 和 Airtable 的多个 axios 请求
- css - 如何为 iPad 应用媒体查询?
- java - apache tomcat 中未显示 ajp/1.3 端口号