windows Python - 安装模块时如何更改默认路径?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8726822/
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
Python - how can I change default path when installing modules?
提问by jonatr
I'm trying to install a Python Module by running a Windows installer (an EXE file). The Problem is that the default python folder and the defualt Installation Library are set To disc D:\ and are grayed out (meaning I can't change it). It might be fine is some places, but in my computer, D is the DVD drive, meaning that no installation is possible.
我正在尝试通过运行 Windows 安装程序(EXE 文件)来安装 Python 模块。问题是默认的 python 文件夹和默认的安装库设置为光盘 D:\ 并且显示为灰色(意味着我无法更改它)。有些地方可能没问题,但是在我的电脑中,D 是 DVD 驱动器,这意味着无法安装。
Is there any way to change this or to overcome this?
有什么办法可以改变这种情况或克服这种情况吗?
回答by Cat Plus Plus
It's not "default folder", and there's a reason there's "found in registry" next to the version. You need to re-register the Python installation if you've moved it, either by installing it again (without removing) in the same folder, or changing the directory saved in registry (HKCU\Software\Python\PythonCore\X.X\InstallPath
, possibly on Wow3264Node
) either manually or using registration script.
它不是“默认文件夹”,并且版本旁边有“在注册表中找到”是有原因的。如果您移动了 Python 安装,则需要重新注册 Python 安装,方法是在同一文件夹中再次安装(不删除),或者手动或使用注册脚本更改注册表(HKCU\Software\Python\PythonCore\X.X\InstallPath
,可能在Wow3264Node
)中保存的目录。
回答by Piotr Dobrogost
Because what you're installing (you don't say what it is) seems to be standard distutils-generated installer (as Cat Plus Plus points out in his comment) you don't have to install it by running installer. You can install it using easy_install program what allows you to choose which Python to use. See my answer to Can I install Python windows packages into virtualenvs?question.
因为你正在安装的东西(你不说它是什么)似乎是标准的 distutils 生成的安装程序(正如 Cat Plus Plus 在他的评论中指出的那样),你不必通过运行 installer 来安装它。您可以使用 easy_install 程序安装它,该程序允许您选择要使用的 Python。请参阅我对Can I install Python windows packages into virtualenvs 的回答吗?题。
EDIT
编辑
Now I see in your comment you're installing setuptools. This complicates things a little bit as this is the package which contains easy_install tool I mentioned above. You have chicken/egg problem here... There's solution for this, however. You can use ez_setupscript to install setuptools without using exe installer.
现在我在您的评论中看到您正在安装 setuptools。这使事情有点复杂,因为这是包含我上面提到的 easy_install 工具的包。您在这里遇到了鸡/蛋问题……但是,对此有解决方案。您可以使用ez_setup脚本来安装 setuptools,而无需使用 exe 安装程序。