【发布时间】:2015-05-08 14:38:52
【问题描述】:
我今天在Win7 X64 上为Python 2.7.9 和3.4.3 进行全新安装,我发现Python27 和Python34 文件夹中没有Script 文件夹作为第一个子级文件夹,但是Tools 中有一个。但是,我在该脚本文件夹中找不到pip,尽管默认情况下pip 应该与Python 一起安装。另一个我正在为我的其他 PC 和笔记本电脑进行相同的安装,有 Script 文件夹(作为 Python27 和 Python34 中的第一级子文件夹)包含 pip。那么发生了什么?如何以这种方式安装pip 以及其他有用的脚本?
[编辑] 我在Python34 中尝试了python -m ensurepip。我收到以下错误:
Ignoring indexes: https://pypi.python.org/simple
Collecting setuptools
Exception:
Traceback (most recent call last):
File "C:\Users\daiyue\AppData\Local\Temp\tmppvmc8dv1\pip-6.0.8-py2.py3-none-
any.whl\pip\basecommand.py", line 232, in main
status = self.run(options, args)
File "C:\Users\daiyue\AppData\Local\Temp\tmppvmc8dv1\pip-6.0.8-py2.py3-none-
any.whl\pip\commands\install.py", line 339, in run
requirement_set.prepare_files(finder)
File "C:\Users\daiyue\AppData\Local\Temp\tmppvmc8dv1\pip-6.0.8-py2.py3-none-
any.whl\pip\req\req_set.py", line 333, in prepare_files
upgrade=self.upgrade,
File "C:\Users\daiyue\AppData\Local\Temp\tmppvmc8dv1\pip-6.0.8-py2.py3-none-
any.whl\pip\index.py", line 326, in find_requirement
file_locations, url_locations = self._sort_locations(locations)
File "C:\Users\daiyue\AppData\Local\Temp\tmppvmc8dv1\pip-6.0.8-py2.py3-none-
any.whl\pip\index.py", line 158, in _sort_locations
sort_path(os.path.join(path, item))
File "C:\Users\daiyue\AppData\Local\Temp\tmppvmc8dv1\pip-6.0.8-py2.py3-none-
any.whl\pip\index.py", line 139, in sort_path
if mimetypes.guess_type(url, strict=False)[0] == 'text/html':
File "C:\Python34\lib\mimetypes.py", line 287, in guess_type
init()
File "C:\Python34\lib\mimetypes.py", line 348, in init
db.read_windows_registry()
File "C:\Python34\lib\mimetypes.py", line 255, in read_windows_registry
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
TypeError: OpenKey() argument 2 must be str without null characters or None, not str
[编辑] 问题是由于HKEY_LOCAL_MACHINE 中的多个空注册表项导致read_windows_registry() 中的mimetypes.py 搜索失败。这是导致解决方案的帖子:
Python ‘pip’ and Windows registry corruption
谢谢
【问题讨论】:
-
为什么你认为pip应该默认安装Python?不是。
-
您使用的是哪个操作系统?
-
您使用捆绑的 pip 作为
python -m pip install SomePackage。如果您同时安装了两个版本,请参阅docs.python.org/3/installing 了解如何为 python3 和 python2 使用各自的 pip。 -
@yole 在 pip 网站上有说明-“Python 2.7.9 及更高版本(在 python2 系列上),Python 3.4 及更高版本默认包含 pip”
-
啊,确实。我不知道它已添加到 2.7.9。
标签: python python-2.7 python-3.x pip