没有名为“pandas”的模块我正在JMP 18中运行一个使用 Python 的 JSL 脚本。在 macOS 上一切正常,但在 Windows 上却出现以下错误:
Traceback (most recent call last):
File "
", line 7, in
ModuleNotFoundError: No module named 'pandas'
In the embedded log is see following:
Creating: C:\\Users\\Admin\\AppData\\Roaming\\JMP\\JMP\\Python\\Python311\\site-packages
This tells me that JMP 18 doesn't install python automatically. Is there a pre-requisite for python be installed?
I am also trying to install this way to ensure the script doesn't fail irrespective of the system:
Python Submit("
import jmputils
required_packages = ['pandas', 'numpy']
# get list of installed python packages
installed = jmputils.jpip('list')
# check & install missing packages
for pkg in required_packages:
if pkg.lower() not in [p.lower() for p in installed]:
print(f'{pkg} not installed — installing...')
jmputils.jpip('install', pkg)
else:
print(f'{pkg} is already installed.')
jmputils.jpip('list')
");
自动化和脚本编写回复:找不到名为“pandas”的模块据我所知,在 JMP18 中,该文件夹会在 Python 首次“运行”时添加,您或许可以通过运行类似以下命令来强制添加:
Python Submit("import jmp");
在 JMP 脚本编辑器中
回复:找不到名为“pandas”的模块Python 报错信息恰恰说明 Python 已经安装了 
要从 JSL 安装 Python 包,请使用:
Python Install Packages( "numpy pandas" );

回复:找不到名为“pandas”的模块谢谢,是的,它创建了 Python 目录和一些软件包。如下:
Python Submit("
import jmputils
required = ['pandas', 'numpy']
# Get installed packages safely
installed = jmputils.jpip('list')
if installed is None:
installed = []
print('Installed packages:', installed)
# Install missing ones
for pkg in required:
if pkg.lower() not in [p.lower() for p in installed]:
print(f'{pkg} not installed — installing...')
jmputils.jpip('install', pkg)
else:
print(f'{pkg} already installed.')
import pandas as pd
import numpy as np
print('pandas and numpy imported successfully!')
");
回复:找不到名为“pandas”的模块是的,这确实帮助我确保文件夹被添加进去了。谢谢。
回复:找不到名为“pandas”的模块使用该导入是我们在 JMP-Python 应用程序中使用的检查方法之一,以确保一切都已设置完毕。
由于诸多原因,我仍然没有使用 JMP19,但它确实能让 JMP 与 Python 的集成更加便捷。如果我没记错的话,JMP19 中集成 Python 就不再需要了,但我还没有验证过。此外,JMP19 还会让检查软件包是否已安装变得更加容易,因为 jmputils 新增了 `is_installed` 方法。
回复:找不到名为“pandas”的模块在 JMP 18 中,解压 site-packages.zip 文件并创建目录是由 jsite.py 脚本完成的。JMP 19 在首次启动 Python 时,会在内部使用 C++ 代码执行此操作。jsite.py 脚本仍然存在,作为备份,用于在 Python 的 Create JPIP CMD() 函数生成命令行 jpip.bat 或 jpip shell 脚本时使用。或者,也可以使用其 Python 等效函数 jmputils.create_jpip( dest_path )。
JMP 19 通过添加 `jmputils.is_installed('package_name')`、`jmputils.package_version('package_name')` 和 `pkg_dict = jmputils.packages()` 改进了可脚本化的包管理。这些功能是 19.0 版本后期添加的,虽然存在,但脚本索引中没有相关文档。后续版本在脚本索引中提供了示例。