如何将 Python 添加到 Windows 注册表

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17872234/
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 09:22:24  来源:igfitidea点击:

How to add Python to Windows registry

pythonregistryenthought

提问by user2621120

I've downloaded Enthought Canopy EPD Free (now Canopy Express) from https://www.enthought.com/products/epd/free/and want to install SciKit Learn (http://sourceforge.net/projects/scikit-learn/files/) which is not part of the basic EPD Free install.

我已经从https://www.enthought.com/products/epd/free/下载了 Enthought Canopy EPD Free(现在是 Canopy Express)并想安装 SciKit Learn ( http://sourceforge.net/projects/scikit-learn /files/) 这不是基本 EPD 免费安装的一部分。

When trying to install it does not find Python in the Windows registry. How do I adjust the registry so that it recognizes the Enthought version of Python?

尝试安装时,它在 Windows 注册表中找不到 Python。如何调整注册表以使其识别 Python 的 Enthought 版本?

回答by Tiger-222

You can find the Python executable with this command:

您可以使用以下命令找到 Python 可执行文件:

C:\> where python.exe

It should return something like:

它应该返回如下内容:

C:\Users\<user>\AppData\Local\enthought\Canopy32\User\python.exe

Open regedit, navigate to HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\<version>\PythonPathand add or edit the default key with this the value found in the first command. Logout, login and python should be found. SciKit can now be installed.

打开 regedit,HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\<version>\PythonPath使用在第一个命令中找到的值导航到并添加或编辑默认键。应该可以找到注销、登录和python。现在可以安装 SciKit。

See Additional “application paths” in https://docs.python.org/2/using/windows.html#finding-modulesfor more details.

有关更多详细信息,请参阅https://docs.python.org/2/using/windows.html#finding-modules 中的其他“应用程序路径” 。

回答by Sameera Nandasiri

I faced to the same problem. I solved it by

我面临同样的问题。我解决了

  1. navigate to HKEY_CURRENT_USER\Software\Python\PythonCore\3.4\InstallPathand edit the default key with the output of C:\> where python.execommand.
  2. navigate to HKEY_CURRENT_USER\Software\Python\PythonCore\3.4\InstallPath\InstallGroupand edit the default key with Python 3.4
  1. HKEY_CURRENT_USER\Software\Python\PythonCore\3.4\InstallPath使用C:\> where python.exe命令的输出导航到并编辑默认键 。
  2. 导航到HKEY_CURRENT_USER\Software\Python\PythonCore\3.4\InstallPath\InstallGroup并编辑默认键Python 3.4

Note: My python version is 3.4 and you need to replace 3.4 with your python version.

注意:我的python版本是3.4,你需要用你的python版本替换3.4。

Normally you can find Registry entries for Python in HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\<version>. You just need to copy those entries to HKEY_CURRENT_USER\Software\Python\PythonCore\<version>

通常,您可以在HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\<version>. 您只需要将这些条目复制到HKEY_CURRENT_USER\Software\Python\PythonCore\<version>

回答by Robo

When installing Python 3.4 the "Add python.exe to Path" came up unselected. Re-installed with this selected and problem resolved.

安装 Python 3.4 时,“将 python.exe 添加到路径”未选中。选择此选项重新安装并解决了问题。

回答by Erik Anderson

I installed ArcGIS Pro 1.4 and it didn't register the Python 3.5.2 it installed which prevented me from installing any add-ons. I resolved this by using the "reg" command in an Administrator PowerShell session to manually create and populate the necessary registry keys/values (where Python is installed in C:\Python35):

我安装了 ArcGIS Pro 1.4,但它没有注册它安装的 Python 3.5.2,这使我无法安装任何附加组件。我通过在管理员 PowerShell 会话中使用“reg”命令手动创建和填充必要的注册表项/值(其中 Python 安装在 C:\Python35 中)解决了这个问题:

reg add "HKLM\Software\Python\PythonCore.5\Help\Main Python Documentation" /reg:64 /ve /t REG_SZ /d "C:\Python35\Doc\Python352.chm"
reg add "HKLM\Software\Python\PythonCore.5\InstallPath" /reg:64 /ve /t REG_SZ /d "C:\Python35\"
reg add "HKLM\Software\Python\PythonCore.5\InstallPath\InstallGroup" /reg:64 /ve /t REG_SZ /d "Python 3.5"
reg add "HKLM\Software\Python\PythonCore.5\PythonPath" /reg:64 /ve /t REG_SZ /d "C:\Python35\Lib;C:\Python35\DLLs;C:\Python35\Lib\lib-tk"

I find this easier than using Registry Editor but that's solely a personal preference.

我发现这比使用注册表编辑器更容易,但这完全是个人喜好。

The same commands can be executed in CMD.EXE session if you prefer; just make sure you run it as Administrator.

如果您愿意,可以在 CMD.EXE 会话中执行相同的命令;只要确保您以管理员身份运行它。

回答by Kevin Murphy

I had the same issue while trying to install bots on a Windows Server. Took me a while to find a solution, but this is what worked for me:

我在尝试在 Windows Server 上安装机器人时遇到了同样的问题。我花了一段时间才找到解决方案,但这对我有用:

  1. Open Command Prompt as Administrator
  2. Copy this: reg add HKLM\SOFTWARE\Python\PythonCore\2.7\InstallPath /ve /t REG_SZ /d "C:\Python27" /fand tailor for your specifications.
  3. Right click and paste the tailored version into Command Prompt and hit Enter!
  1. 以管理员身份打开命令提示符
  2. 复制此内容:reg add HKLM\SOFTWARE\Python\PythonCore\2.7\InstallPath /ve /t REG_SZ /d "C:\Python27" /f并根据您的规格进行定制。
  3. 右键单击并将定制版本粘贴到命令提示符中,然后按 Enter!

Anyway, I hope that this can help someone in the future.

无论如何,我希望这可以帮助将来的某个人。

回答by Firegore

English

英语

In case that it serves to someone, I leave here the Windows 10 base registerfor Python 3.4.4 - 64 bit:

如果它所服务的人,我离开这里的的Windows 10基址寄存器进行的Python 3.4.4 - 64位

Espa?ol

西班牙文

Por si alguien lo necesita todavía, este es el registro base de Windows 10 para Python 3.4.4:

Por si alguien lo necesita todavia, este es el registro base de Windows 10 para Python 3.4.4

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Python\PythonCore.4]
"DisplayName"="Python 3.4 (64-bit)"
"SupportUrl"="http://www.python.org/"
"Version"="3.4.4"
"SysVersion"="3.4"
"SysArchitecture"="64bit"

[HKEY_CURRENT_USER\Software\Python\PythonCore.4\Help]

[HKEY_CURRENT_USER\Software\Python\PythonCore.4\Help\Main Python Documentation]
@="C:\Python34\Doc\python364.chm"

[HKEY_CURRENT_USER\Software\Python\PythonCore.4\Idle]
@="C:\Python34\Lib\idlelib\idle.pyw"

[HKEY_CURRENT_USER\Software\Python\PythonCore.4\IdleShortcuts]
@=dword:00000001

[HKEY_CURRENT_USER\Software\Python\PythonCore.4\InstalledFeatures]

[HKEY_CURRENT_USER\Software\Python\PythonCore.4\InstallPath]
@="C:\Python34\"
"ExecutablePath"="C:\Python34\python.exe"
"WindowedExecutablePath"="C:\Python34\pythonw.exe"

[HKEY_CURRENT_USER\Software\Python\PythonCore.4\PythonPath]
@="C:\Python34\Lib\;C:\Python34\DLLs\"