试图为python3.6安装pip - 找不到setuptools

时间:2018-05-09 21:48:56

标签: python-3.x pip centos7

为什么python认为我缺少setuptools?它就在这里:

[me@my_server site-packages]$ pwd
/usr/lib/python3.6/site-packages
[me@my_server site-packages]$ ll
total 8.0K
drwxr-xr-x. 5 root   83 May  9 21:11 .
drwxr-xr-x. 3 root   26 May  9 21:01 ..
-rw-r--r--. 1 root  126 May  9 21:06 easy_install.py
drwxr-xr-x. 4 root   56 May  9 21:11 pkg_resources
drwxr-xr-x. 2 root    6 Jan  4 16:42 __pycache__
drwxr-xr-x. 4 root 4.0K May  9 21:10 setuptools
[me@my_server site-packages]$ pwd
/usr/lib/python3.6/site-packages
[me@my_server site-packages]$ python3 easy_install.py pip
Traceback (most recent call last):
  File "easy_install.py", line 4, in <module>
    from setuptools.command.easy_install import main
  File "/usr/lib/python3.6/site-packages/setuptools/command/easy_install.py", line 47, in <module>
    from setuptools.package_index import PackageIndex
  File "/usr/lib/python3.6/site-packages/setuptools/package_index.py", line 203, in <module>
    sys.version[:3], require('setuptools')[0].version
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 962, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 849, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'setuptools' distribution was not found and is required by the application



$ ll setuptools/
total 192K
drwxr-xr-x. 4 root 4.0K May  9 21:10 .
drwxr-xr-x. 5 root   83 May  9 21:11 ..
-rw-r--r--. 1 root 6.5K May  9 21:11 archive_util.py
drwxr-xr-x. 3 root 4.0K May  9 21:10 command
-rw-r--r--. 1 root 2.2K May  9 21:11 compat.py
-rw-r--r--. 1 root 6.3K May  9 21:11 depends.py
-rw-r--r--. 1 root  35K May  9 21:11 dist.py
-rw-r--r--. 1 root 1.7K May  9 21:11 extension.py
-rw-r--r--. 1 root 5.3K May  9 21:11 __init__.py
-rw-r--r--. 1 root 2.0K May  9 21:11 lib2to3_ex.py
-rw-r--r--. 1 root 2.2K May  9 21:11 msvc9_support.py
-rw-r--r--. 1 root  39K May  9 21:11 package_index.py
-rw-r--r--. 1 root  431 May  9 21:11 py26compat.py
-rw-r--r--. 1 root  306 May  9 21:11 py27compat.py
-rw-r--r--. 1 root 1.6K May  9 21:11 py31compat.py
drwxr-xr-x. 2 root 4.0K May  9 21:10 __pycache__
-rw-r--r--. 1 root  14K May  9 21:11 sandbox.py
-rw-r--r--. 1 root  201 May  9 21:11 script (dev).tmpl
-rw-r--r--. 1 root  138 May  9 21:11 script.tmpl
-rw-r--r--. 1 root 2.4K May  9 21:11 site-patch.py
-rw-r--r--. 1 root 8.0K May  9 21:11 ssl_support.py
-rw-r--r--. 1 root  981 May  9 21:11 unicode_utils.py
-rw-r--r--. 1 root  293 May  9 21:11 utils.py
-rw-r--r--. 1 root   21 May  9 21:11 version.py
-rw-r--r--. 1 root  714 May  9 21:11 windows_support.py

2 个答案:

答案 0 :(得分:0)

你碰巧在运行Python 2.7吗?您可能已经为Python 2.7安装了setuptools,因此您认为它工作得很好。

为了使用Python 3.6的setuptools,你需要为Python 3.6安装它而不是旧版本。

无论哪种方式,您都可以尝试按原样安装egg文件,然后您可以访问Python 3.6的setuptools。

答案 1 :(得分:0)

您可以使用以下命令安装pip:apt-get install pip