是什么促使你提出这个愿望清单请求?I need to install Python packages in a custom directory on my machine (e.g., C:\lib_jmp_python) using the standard Windows PYTHONUSERBASE environment variable. Currently, if I run jmputils.jpip('install', 'package_name'), my system variable is completely ignored. The jmputils.py script hardcodes the installation paths by forcing its own site.USER_BASE and overwriting the subprocess environment. This makes it impossible to route packages to a custom local folder using standard Python OS variables; everything is forced into the default JMP AppData/ProgramData directories.
您希望看到哪些改进?I would like jmputils.py to respect the system's PYTHONUSERBASE variable if it is defined by the user, and only fall back to the default JMP paths if it is not set. Specifically, in the jpip() function, a simple conditional check could be added:
if 'PYTHONUSERBASE' in os.environ:
site.USER_BASE = os.environ['PYTHONUSERBASE']
elif site.USER_BASE is None:
site.getuserbase()
The exact same logic should be applied to the create_jpip() function when generating the jpip.bat script, replacing the currently hardcoded set PYTHONUSERBASE=%APPDATA%\JMP\JMP\Python with a dynamic check.
为什么这个想法如此重要?对于需要严格控制 Python 环境的用户和 IT 管理员来说,这极具价值。它允许用户将可能体积庞大的 Python 包路由到特定驱动器或自定义目录,而不会破坏 JMP 的隔离环境。最终,它使 JMP 的 Python 集成与标准的 Python 行为保持一致,从而减少开发人员在高效管理软件包时遇到的困难和困惑。
@guillaumebugnon - 感谢您提交愿望。
@guillamebugnon - 我想转达一位开发者关于这个愿望以及即将发布的 JMP 20 版本的一些信息:
JMP 20 版本中的 Python 现在以隔离模式运行,以确保在各种用户环境下行为一致。这意味着嵌入式 Python 现在会忽略所有 PYTHON* 环境变量。
JMP 20 EA 1 及更高版本支持 Python venv 虚拟环境。在 JMP -> 首选项 -> Python 中,有一个面板提供创建和选择虚拟环境的选项,这些虚拟环境可以作为“默认”站点包环境的替代方案。venv 必须由 JMP 创建。虚拟环境必须指向 JMP 提供的 Python 共享库,而不是外部 Python 安装的共享库。创建的虚拟环境可以放置在文件系统或共享驱动器中的任何位置。虚拟环境的选择是一个目录选择对话框,同样,它可以位于文件系统中的任何位置。
创建完成后,虚拟环境 (venv) 可以像任何 Python 虚拟环境一样从终端使用。这包括从命令行激活虚拟环境,以及直接在虚拟环境中使用 pip,而不是在 JMP 中使用 jpip。JMP 创建虚拟环境后,外部脚本可以填充虚拟环境或使用该环境。但是,只有在 JMP 正在运行的情况下才能导入 jmp包。
我建议您下载最新的 JMP EA 版本并试用一下。