Python 3.4 and 2.7 installation no Script folder a

2019-03-23 04:04发布

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

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

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_MACHINE that make read_windows_registry() in mimetypes.py searches failed. Here is the post that leads to the solution:

Python ‘pip’ and Windows registry corruption

thanks

13条回答
手持菜刀,她持情操
2楼-- · 2019-03-23 04:42

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

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

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

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

$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 printed and remove that from the registry (using PowerShell or regedit or whatever tool you prefer).

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

查看更多
地球回转人心会变
3楼-- · 2019-03-23 04:47

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.

  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.

Image 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.
查看更多
别忘想泡老子
4楼-- · 2019-03-23 04:48

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.

查看更多
对你真心纯属浪费
5楼-- · 2019-03-23 04:52

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.

It will work !!!

查看更多
男人必须洒脱
6楼-- · 2019-03-23 04:53

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.

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 ensurepip in both .../python27 and .../python34.

查看更多
唯我独甜
7楼-- · 2019-03-23 04:55

This problem is a official bug: Issue23604 .

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

查看更多
登录 后发表回答