我可以为您进行翻译。以下是需要翻译的内容:
但是出现了以下错误:
此段话的英译中文如下:
我希望在Julia中使用this Python function。
因此,我使用了以下方式:
using PyCall
@pyimport tensorflow
但是出现了以下错误:
ERROR: PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)
The Python package tensorflow could not be found by pyimport. Usually this means
that you did not install tensorflow in the Python version being used by PyCall.
PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package. To install the tensorflow module, you can
use `pyimport_conda("tensorflow", PKG)`, where PKG is the Anaconda
package the contains the module tensorflow, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).
Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python. As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.
) <type 'exceptions.ImportError'>
ImportError('Traceback (most recent call last):\n File "/home/jabou/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>\n from tensorflow.python.pywrap_tensorflow_internal import *\n File "/home/jabou/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in<module>\n _pywrap_tensorflow_internal = swig_import_helper()\n File "/home/jabou/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper\n _mod = imp.load_module(\'_pywrap_tensorflow_internal\', fp, pathname, description)\nImportError: /home/jabou/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _ZN10tensorflow10FileSystem16GetMatchingPathsERKSsPSt6vectorISsSaISsEE\n\n\nFailed to load the native TensorFlow runtime.\n\nSee https://www.tensorflow.org/install/install_sources#common_installation_problems\n\nfor some common reasons and solutions. Include the entire stack trace\nabove this error message when asking for help.',)
File "/home/jabou/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/jabou/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/jabou/.julia/v0.6/Conda/deps/usr/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 72, in <module>
raise ImportError(msg)
我测试了 PyCall
包,并获得了以下信息:
INFO: Testing PyCall
INFO: Python version 2.7.14 from /home/jabou/.julia/v0.6/Conda/deps/usr/lib/libpython2.7, PYTHONHOME=/home/jabou/.julia/v0.6/Conda/deps/usr:/home/jabou/.julia/v0.6/Conda/deps/usr
ENV[PYTHONPATH]=
ENV[PYTHONHOME]=
ENV[PYTHONEXECUTABLE]=
INFO: PyCall tests passed
此段话的英译中文如下:
此外,我定义了环境变量:
ENV["PYTHONPATH"] = "/home/jabou/.julia/v0.6/Conda/deps/usr/lib/libpython2.7"
ENV["PYTHONHOME"]= "/home/jabou/.julia/v0.6/Conda/deps/usr:/home/jabou/.julia/v0.6/Conda/deps/usr"
但是什么都没变...
ENV
字典的键应该是一个字符串,你正在尝试使用一个名为PYTHONPATH
的未定义变量对其进行索引。请尝试ENV["PYTHONPATH"] = "/home/.../libpython2.7"
。 - fredrikekrePYTHONPATH
有效,但我仍然遇到了相同的第一个错误... - Julien