专栏
标签
PyCall库的使用
一般问题
发布于 2025-11-21 00:44:05
查看 9过去220天

你好,我使用默认设置syslab 2025b按照下图官网教程中提供的源代码测试使用PyCall库Description
总是报错,你们官网教程的案例源码也没有找到,我想知道是哪里错了。代码我也上传,报错信息如下:
ERROR: PyError (PyImport_ImportModule

The Python package myfunction.function could not be imported by pyimport. Usually this means
that you did not install myfunction.function in the Python version being used by PyCall.

PyCall is currently configured to use the Python version at:

C:\Users\Public\TongYuan.julia\miniforge3\python.exe

and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the myfunction.function module.
Snipaste_2025-11-21_00-43-02.png
One alternative is to re-configure PyCall to use a different Python
version on your system: set ENV["PYTHON"] to the path/name of the python
executable you want to use, run Pkg.build("PyCall"), and re-launch Julia.

Another alternative is to configure PyCall to use a Julia-specific Python
distribution via the Conda.jl package (which installs a private Anaconda
Python distribution), which has the advantage that packages can be installed
and kept up-to-date via Julia. As explained in the PyCall documentation,
set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia. Then,
To install the myfunction.function module, you can use pyimport_conda("myfunction.function", PKG),
where PKG is the Anaconda package that contains the module myfunction.function,
or alternatively you can use the Conda package directly (via
using Conda followed by Conda.add etcetera).

) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'myfunction'")

Stacktrace:
[1] pyimport(name::String)
@ PyCall C:\Users\Public\TongYuan.julia\packages\PyCall\9ZDyP\src\PyCall.jl:595
[2] top-level scope
@ C:\Users\Public\TongYuan.julia\packages\PyCall\9ZDyP\src\PyCall.jl:639

所属专栏:Syslab基础平台
产品信息:Syslab科学计算环境
科学计算
附件 1 个附件(1kb)

全部回答 1

发布于 2025-11-22 10:37:26

您好,Python代码中只定义了set_path函数,但是没调用,如下图所示,添加“set_path($path)”,同时julia文件复制到“Julia调用python”文件夹下即可运行。
image.png

用户
和原帖交流更多问题细节吧,去
我要发帖 我要发帖
资料中心 资料中心
查看更多>
热门帖子 热门帖子
主要贡献者 主要贡献者
过去7天