无法使用@pyimport在Julia中导入matplotlibmatplotlib.pyplot作为p

2024-09-20 03:59:04 发布

您现在位置:Python中文网/ 问答频道 /正文

您好,我试图使用Julia中的matplotlib命令Pkg.build("PyCall")using PyCall@pyimport matplotlib.pyplot as plt,但我一直收到以下错误消息:

PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)) <type 'exceptions.RuntimeError'>
RuntimeError("Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.",)
  File "/Users/mymac/Library/Python/2.7/lib/python/site-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Users/mymac/Library/Python/2.7/lib/python/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/Users/mymac/Library/Python/2.7/lib/python/site-packages/matplotlib/backends/backend_macosx.py", line 19, in <module>
    from matplotlib.backends import _macosx

下面是我已经尝试过的以下步骤

  • 在Julia内核中尝试运行@pyimport math==>;这是有效的

  • 在Python内核中,我尝试运行import matplotlib as plt==>;它可以工作

  • 我卸载了macos10.13.2上的所有python版本,并重新安装python3.6.5版本。我仍然收到同样的错误信息。

  • 在终端中,我试图运行:$ curl -O https://bootstrap.pypa.io/get-pip.py,然后python3 get-pip.py,但是仍然在Julia中得到错误消息

  • /Users/mymac/Library/中删除Python之后,Julia似乎重新创建了路径/Users/mymac/Library/Python/2.7/

事先非常感谢


Tags: theinpybackendmatplotlibonaslibrary