简体   繁体   English

为什么python27.dll不是python安装文件夹的一部分,而是在Windows系统文件夹中

[英]Why is python27.dll not part of python installed folder but in Windows system folder

As described in: http://bugs.python.org/issue22139 , the python27.dll is installed in the windows systems (in my case C:\\Windows\\Systems32) folder. 如: http ://bugs.python.org/issue22139中所述,python27.dll安装在Windows系统(在我的例子中为C:\\ Windows \\ Systems32)文件夹中。

But I would like to know why? 但我想知道为什么? Why is it not installed next to the python.exe, for example in C:\\Python27\\? 为什么它没有安装在python.exe旁边,例如在C:\\ Python27 \\中?

Reason I ask: I've made a mercurial hook in python that our developers need to use to check if the commit message is valid. 我问的原因:我在python中创建了一个mercurial钩子,我们的开发人员需要使用它来检查提交消息是否有效。 It checks ao for a valid JIRA issue number. 它检查ao是否有有效的JIRA问题编号。 To prevent all our developers to install python themselves and install the required modules manually (a lot of work and errorprone), I zipped the python installation and asked the developers to unzip it locally. 为了防止我们所有的开发人员自己安装python并手动安装所需的模块(很多工作和错误),我压缩了python安装并要求开发人员在本地解压缩它。 But they can't run it, because the python27.dll is missing, or worse, they already have another minor version of python installed, and the hook will fail due to the wrong python27.dll used. 但是他们无法运行它,因为python27.dll丢失了,或者更糟糕的是,他们已经安装了另一个较小版本的python,并且由于使用了错误的python27.dll,钩子将失败。 Confusing. 混乱。 If I just add the python27.dll (the correct version) to the zip file, it all seems to work great. 如果我只是将python27.dll(正确的版本)添加到zip文件中,它似乎都很好用。 So, why is it not installed in that location in the first place? 那么,为什么它首先没有安装在那个位置? What is the advantage of installing it in C:\\Windows\\System32? 在C:\\ Windows \\ System32中安装它有什么好处?

Hope someone can explain this to me! 希望有人能向我解释一下! Thanks in advance, Tallandtree. 在此先感谢Tallandtree。

I use the Anaconda Python distribution from http://continuum.io . 我使用http://continuum.io上的Anaconda Python发行版。 They put python27.dll into c:\\anaconda right next to its python.exe. 他们将python27.dll放在其python.exe旁边的c:\\ anaconda中。 This distribution is also superior in that you can have multiple python environments with precisely the packages you need and switch between them easily ( http://conda.pydata.org/docs/using/envs.html ). 这种分布也是优越的,因为你可以拥有多个python环境,只需要你需要的软件包,并轻松地在它们之间切换( http://conda.pydata.org/docs/using/envs.html )。 You can also get the package list of one of your environments and distribute it to others. 您还可以获取其中一个环境的包列表并将其分发给其他人。

I recommend this Python distribution over the one from python.org and Enthought, because of this issue. 由于这个问题,我建议使用python.org和Enthought上的Python发行版。

.dll s are quite windows-specific files. .dll是特定于Windows的文件。 I imagine you will have shared object (.so) files for LINUX/UNIX-specific Python stuff? 我想你将拥有LINUX / UNIX特定Python东西的共享对象(.so)文件? You said your developer's couldn't run it, because they didn't have the correct DLL (ie the one relevant to their Python installation). 你说你的开发人员无法运行它,因为他们没有正确的DLL(即与他们的Python安装相关的DLL)。

Also, the advantage of installing it to System32 is that it's in the default PATH. 此外,将其安装到System32的优点是它在默认的PATH中。 Additionally, if any other application is internally using Python and require access to the .dll file, and also NOT reference your Python directory, they will probably be looking for a location that "Actually" exists (I wanted to say guaranteed to exist, but......never mind). 另外,如果任何其他应用程序在内部使用Python并且需要访问.dll文件,并且也没有引用您的Python目录,那么他们可能会寻找“实际”存在的位置(我想说保证存在,但是......没关系)。 That location would be `C:/windows/Systems32'. 该位置将是`C:/ windows / Systems32'。

I found it to work just fine to put python27.dll in the Python directory (c:\\Python27 or wherever). 我发现将python27.dll放在Python目录(c:\\ Python27或其中)可以正常工作。 As long as it's in the PATH, it seems to work. 只要它在PATH中,它似乎有效。 I did this for a "relocatable" installation of Python. 我这样做是为了“可重定位”的Python安装。 I can copy the installation directory to a Windows machine that has no Python installed, set the PATH to include that directory, and run Python, including all the libraries I had installed with pip install on the original machine. 我可以将安装目录复制到没有安装Python的Windows机器上,将PATH设置为包含该目录,然后运行Python,包括我在原始机器上安装了pip install所有库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM