简体   繁体   English

Jupyter(IPython)笔记本numpy / pandas / matplotlib错误(FreeBSD)

[英]Jupyter (IPython) notebook numpy/pandas/matplotlib error (FreeBSD)

I am trying to set up a Jupyter notebook server at home. 我正在尝试在家里设置Jupyter笔记本服务器。 It has taken me a long time, but I have build and installed Python 3.4 and all the required packages from FreeBSD ports successfully. 我花了很长时间,但是我已经从FreeBSD端口成功构建并安装了Python 3.4和所有必需的软件包。 The notebook server is up and running fine, except every time when I try to import numpy: 笔记本服务器正常运行,但每次尝试导入numpy时除外:

In[1]: import numpy

The following errors occur: 发生以下错误:

ImportError                               Traceback (most recent call last)
<ipython-input-1-5a0bd626bb1d> in <module>()
----> 1 import numpy

/usr/local/lib/python3.4/site-packages/numpy/__init__.py in <module>()
    178         return loader(*packages, **options)
    179 
--> 180     from . import add_newdocs
    181     __all__ = ['add_newdocs',
    182                'ModuleDeprecationWarning',

/usr/local/lib/python3.4/site-packages/numpy/add_newdocs.py in <module>()
     11 from __future__ import division, absolute_import, print_function
     12 
---> 13 from numpy.lib import add_newdoc
     14 
     15 ###############################################################################

/usr/local/lib/python3.4/site-packages/numpy/lib/__init__.py in <module>()
      6 from numpy.version import version as __version__
      7 
----> 8 from .type_check import *
      9 from .index_tricks import *
     10 from .function_base import *

/usr/local/lib/python3.4/site-packages/numpy/lib/type_check.py in <module>()
      9            'common_type']
     10 
---> 11 import numpy.core.numeric as _nx
     12 from numpy.core.numeric import asarray, asanyarray, array, isnan, \
     13                 obj2sctype, zeros

/usr/local/lib/python3.4/site-packages/numpy/core/__init__.py in <module>()
     12         os.environ[envkey] = '1'
     13         env_added.append(envkey)
---> 14 from . import multiarray
     15 for envkey in env_added:
     16     del os.environ[envkey]

ImportError: /lib/libgcc_s.so.1: version GCC_4.6.0 required by /usr/local/lib/gcc48/libgfortran.so.3 not found

The error messages for importing pandas and matplotlib are different, but I suspect that has something to do with this numpy import error. 导入熊猫和matplotlib的错误消息是不同的,但是我怀疑与numpy导入错误有关。

Strangely, all 3 packages work fine in Python and IPython consoles with no problems at all! 奇怪的是,所有3个软件包都可以在Python和IPython控制台中正常工作,完全没有问题! I have googled and made the following attempts: 我用谷歌搜索并做了以下尝试:

    delete and reinstall numpy -> no change
    append numpy directory to sys.path -> no change
    install a lot of other external packages just to see if it's only related to numpy -> they are all working fine in both consoles and notebook, except scipy giving some error related to numpy

Thank you for your help! 谢谢您的帮助!

My gcc is version 4.2.1. 我的gcc版本是4.2.1。 I have fixed this by setting the LD_LBRARY_PATH to /usr/local/lib/gcc48. 我已通过将LD_LBRARY_PATH设置为/ usr / local / lib / gcc48来解决此问题。 gcc48 is already installed in my system. 我的系统中已经安装了gcc48。 To avoid setting the path every time, I've added the following line to /.cshrc: 为了避免每次都设置路径,我在/.cshrc中添加了以下行:

setenv  LD_LIBRARY_PATH /usr/local/lib/gcc48

edit: This won't work is you want to start the notebook server automatically by adding to crontab: 编辑:这是行不通的,因为您想通过添加到crontab自动启动笔记本服务器:

@reboot /usr/local/bin/jupyter-notebook

the same error appears when trying to import numpy and modules depending on numpy 尝试导入numpy和取决于numpy的模块时,会出现相同的错误

I fixed this by making a copy of /usr/local/bin/jupyter-notebook and added the following lines: 我通过复制/ usr / local / bin / jupyter-notebook来解决此问题,并添加了以下几行:

    import sys
    import re
    ----------------- add these 2 lines below --------------
    import os
    os.environ['LD_LIBRARY_PATH'] = '/usr/local/lib/gcc48'
    ....

Add the new file to crontab instead of jupyter-notebook . 将新文件而不是jupyter-notebook添加到crontab中。

The issue is not with your python modules. 问题不在于您的python模块。 The error message at the bottom, where it says ImportError: /lib/libgcc_s.so.1: version GCC_4.6.0 required by /usr/local/lib/gcc48/libgfortran.so.3 not found indicates that it's a dependency error with the Fortran library. 底部的错误消息显示ImportError: /lib/libgcc_s.so.1: version GCC_4.6.0 required by /usr/local/lib/gcc48/libgfortran.so.3 not found表明它是与Fortran库。 Apparently it wants gcc 4.6 or higher, and apparently you have a lower version installed. 显然,它希望使用gcc 4.6或更高版本,并且显然您安装了较低版本。 Not being familiar with Python libraries or your setup, my guess is that it could be an issue with /usr/ports/devel/py-fortran . 我不熟悉Python库或您的设置,我想这可能是/usr/ports/devel/py-fortran I would recommend checking the gcc version on your machine with gcc -v and whatever fortran-related ports you have installed with pkg info and then take it from there. 我建议您使用gcc -v检查您计算机上的gcc版本,并使用pkg info安装与fortran相关的任何端口,然后从那里获取它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM