[英]How to add a directory to the system path environment variable using cx_Freeze?
I have developed an application in Python and I am distributing the .exe of the app by freezing the code with cx_Freeze
. 我已经用Python开发了一个应用程序,并通过使用cx_Freeze
冻结代码来cx_Freeze
该应用程序的.exe 。
A package in my application ( cx_Oracle
) requires the user to add a directory to the PATH environment variable. 我的应用程序中的软件包 ( cx_Oracle
)要求用户向PATH环境变量添加目录。
Is there a way to do so making use of bdist_msi
command in cx_Freeze
setup script without having the user to do it manually? 有没有办法在用户不需要手动执行的情况下,在cx_Freeze
安装脚本中使用bdist_msi
命令?
For example, if I wanted to add C:\\folder1
to the PATH , how should I modify the following code? 例如,如果要将C:\\folder1
添加到PATH ,应如何修改以下代码?
'bdist_msi': {
'upgrade_code': upgrade_code,
'add_to_path': True,
'environment_variables': [
("E_MYAPP_VAR", "=-*MYAPP_VAR", "1", "TARGETDIR")
]
}
Try with 试试看
'bdist_msi': {
'upgrade_code': upgrade_code,
'add_to_path': True,
'environment_variables': [
("E_MYAPP_VAR", "=-*Path", r"[~];C:\folder1", "TARGETDIR")
]
}
See the implementation of the add_to_path
option in https://github.com/anthony-tuininga/cx_Freeze/blob/master/cx_Freeze/windist.py and the documentation of the MSI Environment Table . 请参阅https://github.com/anthony-tuininga/cx_Freeze/blob/master/cx_Freeze/windist.py中的add_to_path
选项的实现以及MSI环境表的文档。
But please BE CAREFUL: I've not tested this code and loosing the existing path information may prevent the computer from booting according to that documentation. 但是请小心:我尚未测试此代码,并且丢失现有路径信息可能会阻止计算机根据该文档启动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.