我的解决方案是安装一个 python 版本和所需的包。我的解决方案结构是:
-> Python
-> Program
-> run.bat
第一个Python目录是包含所有可执行文件和包的 Python 环境。目录Program包含项目文件和run.bat,它们设置环境以使用此本地安装。在目录Python\Scripts
里面有一个存档来激活环境。我的脚本代码是:
运行.bat
cls
@ECHO OFF
call %~dp0Python\Scripts\activate.bat
ECHO Starting Program....
%~dp0Python\python %~dp0ProgramData\starter.py
activate.bat
@echo off
set "VIRTUAL_ENV=%~dp0\Python"
if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
) else (
if not defined PROMPT (
set "PROMPT=$P$G"
)
if not defined VIRTUAL_ENV_DISABLE_PROMPT (
set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
)
)
if not defined VIRTUAL_ENV_DISABLE_PROMPT (
set "PROMPT=(64bits) %PROMPT%"
)
REM Don't use () to avoid problems with them in %PATH%
if defined _OLD_VIRTUAL_PYTHONHOME goto ENDIFVHOME
set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
:ENDIFVHOME
set PYTHONHOME=
REM if defined _OLD_VIRTUAL_PATH (
if not defined _OLD_VIRTUAL_PATH goto ENDIFVPATH1
set "PATH=%_OLD_VIRTUAL_PATH%"
:ENDIFVPATH1
REM ) else (
if defined _OLD_VIRTUAL_PATH goto ENDIFVPATH2
set "_OLD_VIRTUAL_PATH=%PATH%"
:ENDIFVPATH2
set "PATH=%VIRTUAL_ENV%;%PATH%"
This solution works for in my both application (64 bits and 32 bits) installation.