0

我正在使用 PyCall 在 Julia 中调用 Python。我的环境设置为我的 Anaconda 发行版(xxx如下),并且 PyCall 可以正确构建。

如果我使用

using PyCall
np = pyimport("numpy")

我明白了

ERROR: LoadError: PyError (PyImport_ImportModule

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

PyCall is currently configured to use the Python version at:

xxx\Anaconda3\python.exe

and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the numpy module.

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 numpy module, you can use `pyimport_conda("numpy", PKG)`,
where PKG is the Anaconda package the contains the module numpy,
or alternatively you can use the Conda package directly (via
`using Conda` followed by `Conda.add` etcetera).

) <class 'ImportError'>
ImportError('DLL load failed: Das angegebene Modul wurde nicht gefunden.')
  File "xxx\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "xxx\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit 

尽管 numpy 安装在命名目录中。

4

0 回答 0