简体   繁体   English

将Python二进制模块安装到Windows中的自定义位置

[英]Installing Python binary modules to a custom location in Windows

Suppose that I want to install a binary module for Python on Windows. 假设我想在Windows上为Python安装二进制模块。 Suppose that the module is distributed as a pre-built installer xxx-nnnwin32-py2.7.exe , prepared using distutils. 假设模块作为预构建的安装程序xxx-nnnwin32-py2.7.exe ,使用distutils准备。

My problem is that the installer insists on installing the package into whatever Python directory he finds in the registry. 我的问题是安装程序坚持将软件包安装到他在注册表中找到的任何Python目录中。 However, I have this tiny "portable" Python directory on a flash drive that I use from time to time and need to have packages installed there. 但是,我在闪存驱动器上有这个微小的“可移植”Python目录,我不时使用它并需要在那里安装软件包。 That directory is not marked in the registry. 该目录未在注册表中标记。

So far what I was doing was simply unpacking the installer and manually copying the files into Lib/site-packages . 到目前为止,我所做的只是解压缩安装程序并手动将文件复制到Lib/site-packages But perhaps there is a smarter alternative? 但也许还有一个更聪明的选择呢? Could I hack the distutils installer somehow to let me specify the target Python directory (as some other installers do)? 我能不能以某种方式破解distutils安装程序,让我指定目标Python目录(正如其他一些安装程序那样)?

PS: Note that easy-install is not an option, as it insists on compiling packages from source, whereas I want to install the precompiled package. PS:请注意,easy-install不是一个选项,因为它坚持从源代码编译包,而我想安装预编译包。

You can install binary packages using easy_install and it doesn't require compilation: 可以使用easy_install安装二进制包,它不需要编译:

easy_install binary_installer_built_with_distutils.exe

See Can I install Python windows packages into virtualenvs? 请参阅我可以将Python Windows软件包安装到virtualenvs中吗?

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

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