Python 3.4 和 2.7 安装没有 Script 文件夹,也没有安装 pip

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28908142/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 03:53:02  来源:igfitidea点击:

Python 3.4 and 2.7 installation no Script folder and no pip installed

pythonpython-2.7python-3.xpip

提问by daiyue

I was doing a fresh installation for Python 2.7.9and 3.4.3on Win7 X64today, and I found that there is no Scriptfolder in Python27and Python34folder as first child level folder, but there is one in Tools. However, I couldn't find pipwithin that Script folder, although pipshould be installed with Pythonby default. The other I was doing the same installation for my other PC and laptop, there was Scriptfolder (as first level child folder in Python27and Python34) containing pip. So what is going on? how to install pipand maybe other useful scripts this way?

我在做一个全新安装的Python 2.7.9,并3.4.3Win7 X64今天,我发现,没有Script在文件夹Python27Python34文件夹中的第一个孩子一级文件夹,但有是一家从事Tools。但是,我pip在该 Script 文件夹中找不到,尽管默认情况下pip应该安装Python。其他的我在做同样的安装我的其他PC和笔记本电脑,有Script文件夹(如在第一级子文件夹Python27Python34)含pip。那么发生了什么?如何以pip这种方式安装以及其他有用的脚本?

[EDIT] I tried python -m ensurepipin Python34. I got the following errors:

[编辑] 我python -m ensurepipPython34. 我收到以下错误:

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

[EDIT] The problem is due to multiple null Registry keys in HKEY_LOCAL_MACHINEthat make read_windows_registry()in mimetypes.pysearches failed. Here is the post that leads to the solution:

[编辑]这个问题是由于在多个空的注册表项HKEY_LOCAL_MACHINE,使read_windows_registry()mimetypes.py失败的搜索。这是导致解决方案的帖子:

Python ‘pip' and Windows registry corruption

Python 'pip' 和 Windows 注册表损坏

thanks

谢谢

回答by Terry Jan Reedy

If you used the PSF (python.org) .msi Windows installers, pip (and dependencies) should be installed in pythonxy/Lib/site-packages for 3.4.0+ and 2.7.9+. There should also be pythonxy/Scripts containing about 5 .exes. This is the last part of the install process. A command prompt window should briefly appear. Perhaps you did not have [ ] install pip checked when doing the installs (although this should have been checked by default). Perhaps there was an error that you missed.

如果您使用 PSF (python.org) .msi Windows 安装程序,则应在 pythonxy/Lib/site-packages 中为 3.4.0+ 和 2.7.9+ 安装 pip(和依赖项)。还应该有包含大约 5 个 .exe 的 pythonxy/Scripts。这是安装过程的最后一部分。命令提示符窗口应该会短暂出现。也许您在安装时没有检查 [ ] install pip (尽管默认情况下应该检查)。也许您错过了一个错误。

In any case, you should have pythonxy/Lib/ensurepip/* present for both 2.7 and 3.4 and you should be able to run this module now. In Command Prompt, try python -m ensurepipin both .../python27 and .../python34.

在任何情况下,您都应该为 2.7 和 3.4 提供 pythonxy/Lib/ensurepip/* 并且您现在应该能够运行此模块。在命令提示符中,同时尝试python -m ensurepip.../python27 和 .../python34。

回答by Max1234-ITA

I ran into the same issue today while trying to install Python 2.7.13 in my computer; after some investigation I realized that v.3.60 ("Anaconda") was already present (it came along with Microsoft Visual Studio 2017, which I've installed a couple weeks ago).

我今天在尝试在我的计算机中安装 Python 2.7.13 时遇到了同样的问题;经过一番调查,我意识到 v.3.60(“Anaconda”)已经存在(它与我几周前安装的 Microsoft Visual Studio 2017 一起提供)。

I suspected of some path mismatch in the registry, so I tried removing both Python v. 3.60 and 2.17, and cleaning up the Registry by deleting the HKCU\Software\Pythonkey (which, due to some reason, was still present). After this, I was able to correctly install version 2.7.13, and this time the \scripts folder is present, with all the expected contents.

我怀疑注册表中存在某些路径不匹配,因此我尝试删除 Python v. 3.60 和 2.17,并通过删除HKCU\Software\Python键(由于某种原因仍然存在)来清理注册表。在此之后,我能够正确安装版本 2.7.13,这次 \scripts 文件夹存在,其中包含所有预期的内容。

I don't know if installing v. 3.6 again would cause any problem: I'm not going to try this for the time since I'm currently developing for v.2.7.

我不知道再次安装 v. 3.6 是否会导致任何问题:由于我目前正在为 v.2.7 进行开发,因此暂时不会尝试这个。

Hope this can be of some help, anyway.

无论如何,希望这可以有所帮助。

Max - Italy

Max - 意大利



EDIT: I've made some further investigation and think I've discovered the reason why (in my case), the \Scripts folder was missing: the path where I was going to install Python is in virtual drive.

编辑:我进行了一些进一步的调查,并认为我已经发现了(在我的情况下)\Scripts 文件夹丢失的原因:我要安装 Python 的路径在虚拟驱动器中。

In my computer I only have one partition (C:), and i've mapped a folder (C:\Development) as D:, then I tried to install Python on D:\Python27; apparently this is not "good" and causes some problem in the installer.

在我的计算机中,我只有一个分区 (C:),并且我将一个文件夹 (C:\Development) 映射为 D:,然后我尝试在 D:\Python27 上安装 Python;显然这不是“好”,并且会导致安装程序出现一些问题。

After discovering that, I tried installing to the real path, and now everything seems to be OK.

发现后,我尝试安装到真实路径,现在似乎一切正常。

Max.

最大限度。

回答by J3soon

This problem is a official bug: Issue23604 .

此问题是官方错误:Issue23604

I had encountered the same problem, and fixed it successfully using the method in Swarley's Blog.

我遇到了同样的问题,并使用Swarley's Blog 中的方法成功修复了它 。

回答by Aaron Doyle

Based on a combination of whats here, and what I found elsewhere, here is how I fixed it:

基于这里的内容和我在其他地方找到的内容的组合,这是我修复它的方法:

Uninstall whatever is installed already. Go to regedit and HKLM/SOFTWARE/Python and delete the whole python section. Reinstall Python

卸载已经安装的任何东西。转到 regedit 和 HKLM/SOFTWARE/Python 并删除整个 python 部分。重新安装 Python

This installed with the scripts folder this time.

这次安装了脚本文件夹。

Hope this helps someone.

希望这可以帮助某人。

回答by ForNeVeR

Guess what? In case you have NetBeans(or probably GlassFish) installed, then it could break installation for pip!

你猜怎么着?如果您安装了NetBeans(或者可能是GlassFish),那么它可能会破坏pip 的安装!

Details:there's a bugin NetBeans installer that could sometimes break the Windows registry in a way that's not expected by other installers.

详细信息:NetBeans 安装程序中存在一个错误,有时可能会以其他安装程序不希望的方式破坏 Windows 注册表。

@J3soon's answerwas close, but Swarley's blog posthaven't fixed the problem in my environment, because it wasn't a null character but was another kind of registry corruption.

@J3soon 的回答很接近,但Swarley 的博客文章并没有解决我环境中的问题,因为它不是空字符而是另一种注册表损坏

And here's how I got rid of the issue. Run the following PowerShell script:

这就是我摆脱这个问题的方法。运行以下 PowerShell 脚本:

$local_key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*'
$machine_key = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*'
$machine_key6432 = 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
$items = Get-ChildItem @($local_key, $machine_key, $machine_key6432)
$ErrorActionPreference = 'Stop'

foreach ($item in $items) {
    Write-Output $item.PSPath
    $null = Get-ItemProperty $item.PSPath
}

It will write the registry key names to the output. In case it prints an error, take the one last key it printedand remove that from the registry (using PowerShell or regeditor whatever tool you prefer).

它将注册表项名称写入输出。如果它打印错误,请获取它打印的最后一个键并将其从注册表中删除(使用 PowerShell 或regedit您喜欢的任何工具)。

After that, reinstall Python, and it should install pip as intended.

之后,重新安装 Python,它应该按预期安装 pip。

回答by prateek shrivastav

I am using python 3.6.2 and faced a similar issue of missing scripts folder(also pip script) in python folder. I have done following things to add scripts folder again to python.

我正在使用 python 3.6.2 并面临 python 文件夹中缺少脚本文件夹(也是 pip 脚本)的类似问题。我已完成以下操作将脚本文件夹再次添加到 python。

  1. Goto - Control Panel\All Control Panel Items\Programs and Features then look for python program and try to uninstall it. A pop window will appear which shows the following image.
  1. Goto - Control Panel\All Control Panel Items\Programs and Features 然后查找 python 程序并尝试卸载它。将出现一个弹出窗口,显示下图。

Image Python

图像 Python

Try to REPAIR the installed program that should fix the issue.

尝试修复应该解决问题的已安装程序。

  1. Otherwise click on MODIFY and tick on pip check box and Add Python to environment variables checkbox, then install it. This should fix the issue.
  1. 否则单击修改并勾选 pip 复选框和将 Python 添加到环境变量复选框,然后安装它。这应该可以解决问题。

回答by Pranav

Even I was facing this issue. I solved it by doing the following steps:

甚至我也面临这个问题。我通过执行以下步骤解决了它:

  1. Uninstall python. (you can use the installer(python-2.7.xx.msi) to perform the uninstall. Select the option 'Remove Python'on double clicking the installer.)

  2. Edit the environment variable 'Path', and remove the python directory path. ( To change the environment variable, right click on 'This PC', click properties, click 'Advanced System Properties' ->Environment Variables)

  3. Remove the environment variable 'Python Path' if present.

  4. Now reinstall python.

  1. 卸载蟒蛇。(您可以使用安装程序(python-2.7.xx.msi)执行卸载。双击安装程序选择“删除Python”选项。)

  2. 编辑环境变量 'Path',并删除 python 目录路径。(要更改环境变量,右键单击“此PC”,单击属性,单击“高级系统属性”->环境变量)

  3. 如果存在,请删除环境变量“Python Path”。

  4. 现在重新安装python。

It will work !!!

它会起作用!!!

回答by girishlc

Actually Scipts folder will not create after installing python, you have to manually create this folder and then install pip, then you can find the required files in this directory.

实际上安装python后不会创建scipts文件夹,你必须手动创建这个文件夹然后安装pip,然后你才能在这个目录中找到所需的文件。

回答by AnirudhKonduru

Had the same issue, reinstalling didn't help.

有同样的问题,重新安装没有帮助。

Finally fixed it by running python -m ensurepipas administrator.

最后通过python -m ensurepip管理员身份运行修复它。

回答by Ashish Gupta