Jupyter (IPython) notebook numpy/pandas/matplotlib error (FreeBSD) - python

I am trying to set up a Jupyter notebook server at home. 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. The notebook server is up and running fine, except every time when I try to import 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.
Strangely, all 3 packages work fine in Python and IPython consoles with no problems at all!
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.
I have fixed this by setting the LD_LBRARY_PATH to /usr/local/lib/gcc48. gcc48 is already installed in my system.
To avoid setting the path every time, I've added the following line to /.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:
#reboot /usr/local/bin/jupyter-notebook
the same error appears when trying to import numpy and modules depending on numpy
I fixed this by making a copy of /usr/local/bin/jupyter-notebook and added the following lines:
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.

The issue is not with your python modules. 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. Apparently it wants gcc 4.6 or higher, and apparently you have a lower version installed. Not being familiar with Python libraries or your setup, my guess is that it could be an issue with /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.

Related

ImportError: No module named request when importing BeakerX into Jupyter

I am trying to import beakerx into my jupyter environment like so:
from beakerx import *
However, I get the following error:
ImportError Traceback (most recent call last)
<ipython-input-19-4c368a35c7cf> in <module>()
----> 1 from beakerx import *
/Users/vivaksoni1/venv/lib/python2.7/site-packages/beakerx/__init__.py in <module>()
13 # limitations under the License.
14
---> 15 from .runtime import BeakerX
16 from .plot import *
17 from .easyform import *
/Users/vivaksoni1/venv/lib/python2.7/site-packages/beakerx/runtime.py in <module>()
16
17 import os, json, pandas, numpy
---> 18 import urllib.request, urllib.parse, urllib.error, urllib.request, urllib.error, urllib.parse, IPython, datetime, calendar, math, traceback, time
19 from traitlets import Unicode
20
ImportError: No module named request
I am not sure what this error means? Also, it seems to be looking into python2.7 directories even though this is a python 3 script? I installed beakerx using: pip3 install beakerx and can see the files in the right folder within the right folder:
anaconda3/pkgs/beakerx-0.12.2-py36_2/lib/python3.6/site-packages/beakerx
This seems to be how every other module is stored but I cannot get it working for some reason. Can anyone help?

plotly cannot import name exceptions

I know this question has been asked before but there are very few solutions given and I don't understand the ones that are provided.
I'm trying to import my module packages and I receive the error below. The strange thing is this was all working 2 days ago and I haven't really done anything since with it so I can't understand why this is now appearing.
import plotly.offline as pyo
from plotly.graph_objs import *
from plotly import tools
import plotly.plotly as py
import pandas as pd
import math as m
pyo.offline.init_notebook_mode()
this returns the following error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-f7b4615963aa> in <module>()
----> 1 import plotly.offline as pyo
2 from plotly.graph_objs import *
3 from plotly import tools
4 import plotly.plotly as py
5 import pandas as pd
C:\Users\Lewis\Anaconda3\Lib\site-packages\plotly\plotly\__init__.py in <module>()
8
9 """
---> 10 from . plotly import (
11 sign_in,
12 update_plot_options,
C:\Users\Lewis\Anaconda3\Lib\site-packages\plotly\plotly\plotly.py in <module>()
28 from requests.compat import json as _json
29
---> 30 from plotly import exceptions, files, session, tools, utils
31 from plotly.api import v1, v2
32 from plotly.plotly import chunked_requests
ImportError: cannot import name 'exceptions'
I've tried updating Plotly but this didn't do anything either. Could this be because I installed Jupyter notebook with my Anaconda installation, and my Lib\site-packages directory is within the Anaconda3 dir? Can't imagine this would be the cause but I can't think of much else. Any ideas?
[edit]
import sys
sys.path
['',
'C:\\Users\\Lewis\\Anaconda3\\Lib\\site-packages\\plotly',
'C:\\Users\\Lewis\\Anaconda3\\python36.zip',
'C:\\Users\\Lewis\\Anaconda3\\DLLs',
'C:\\Users\\Lewis\\Anaconda3\\lib',
'C:\\Users\\Lewis\\Anaconda3',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\Sphinx-1.5.6-py3.6.egg',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\setuptools-27.2.0-py3.6.egg',
'C:\\Users\\Lewis\\Anaconda3\\lib\\site-packages\\IPython\\extensions',
'C:\\Users\\Lewis\\.ipython']
in my case, after doing the upgrade like #Max above suggested, restarting the kernel finally fixed the problem
pip install --upgrade plotly
run the above command. it will work

Datashader has snappy error

I was using python's datashader 0.5.0 package to plot population density information, generally following the tutorial https://www.continuum.io/blog/developer-blog/analyzing-and-visualizing-big-data-interactively-your-laptop-datashading-2010-us . I installed datashader using conda install -c bokeh datashader=0.5.0.
All was fine. Though perhaps unrelated, things seemed to break as soon as I installed the haloviews and geoviews packages. After installing these additional packages, I can no longer import datashader and my once working code no longer runs. When importing datashader, I get the following error:
AttributeError: module 'snappy' has no attribute 'compress'
I am running on windows 10, anaconda python 3.5.3.
Perhaps I'm going down the wrong rabbit hole, but I thought perhaps it was the snappy package. I ran "conda install -c conda-forge snappy=1.1.4". conda list reveals that snappy is installed. Snappy does import. The snappy.compress object is not found. My issue seems related to the following SO post as I also had a fastparquet error when trying geoviews: error with snappy while importing fastparquet in python
When running import snappy, print(snappy.__filename__) gives the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-5-b8565733b383> in <module>()
----> 1 import snappy; print(snappy.__file__)
AttributeError: module 'snappy' has no attribute '__file__'
I also tried uninstalling through both conda and pip just in case. Still no joy.
Running "pip install python-snappy" results in a "failed building wheel for python-snappy" error preceded with " error: Microsoft Visual C++ 14.0 is required..." So I went and got the "Microsoft Visual C++ Redistributable for Visual Studio 2017" and ran it, but had no change.
Any thoughts on how to resolve this? For reference, the full error on datashader import is as follows:
--------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-7-3d7b1ff9e530> in <module>()
----> 1 import datashader
C:\Python\lib\site-packages\datashader\__init__.py in <module>()
3 __version__ = '0.5.0'
4
----> 5 from .core import Canvas
6 from .reductions import (count, any, sum, min, max, mean, std, var, count_cat,
7 summary)
C:\Python\lib\site-packages\datashader\core.py in <module>()
3 import numpy as np
4 from datashape.predicates import istabular
----> 5 from odo import discover
6 from xarray import DataArray
7
C:\Python\lib\site-packages\odo\__init__.py in <module>()
63 from .backends.url import URL
64 with ignoring(ImportError):
---> 65 from .backends.dask import dask
66
67
C:\Python\lib\site-packages\odo\backends\dask.py in <module>()
8
9 from dask.array.core import Array, from_array
---> 10 from dask.bag.core import Bag
11 import dask.bag as db
12 from dask.compatibility import long
C:\Python\lib\site-packages\dask\bag\__init__.py in <module>()
1 from __future__ import absolute_import, division, print_function
2
----> 3 from .core import (Bag, Item, from_sequence, from_url, to_textfiles, concat,
4 from_delayed, map_partitions, bag_range as range,
5 bag_zip as zip, bag_map as map)
C:\Python\lib\site-packages\dask\bag\core.py in <module>()
30
31 from ..base import Base, normalize_token, tokenize
---> 32 from ..bytes.core import write_bytes
33 from ..compatibility import apply, urlopen
34 from ..context import _globals, defer_to_globals
C:\Python\lib\site-packages\dask\bytes\__init__.py in <module>()
2
3 from ..utils import ignoring
----> 4 from .core import read_bytes, open_files, open_text_files
5
6 from . import local
C:\Python\lib\site-packages\dask\bytes\core.py in <module>()
7 from warnings import warn
8
----> 9 from .compression import seekable_files, files as compress_files
10 from .utils import (SeekableFile, read_block, infer_compression,
11 infer_storage_options, build_name_function)
C:\Python\lib\site-packages\dask\bytes\compression.py in <module>()
30 with ignoring(ImportError):
31 import snappy
---> 32 compress['snappy'] = snappy.compress
33 decompress['snappy'] = snappy.decompress
34
AttributeError: module 'snappy' has no attribute 'compress'
It turns out that in adding packages, something messed up the snappy install. I followed this solution: How to install snappy C libraries on Windows 10 for use with python-snappy in Anaconda?
It was a snappy error, not a datashader issue, but I'll leave the post in case anyone has the same series of issues.

AttributeError: module 'numpy' has no attribute 'version'

I am working on learning how to use pandas in ipython notebook:
import pandas as pd
But I get the following error:
AttributeError Traceback (most recent call last)
<ipython-input-17-c7ecb2b0a99d> in <module>()
----> 1 from pandas import *
D:\Anaconda\lib\site-packages\pandas\__init__.py in <module>()
20
21 # numpy compat
---> 22 from pandas.compat.numpy import *
23
24 try:
D:\Anaconda\lib\site-packages\pandas\compat\numpy\__init__.py in <module>()
8
9 # numpy versioning
---> 10 _np_version = np.version.short_version
11 _nlv = LooseVersion(_np_version)
12 _np_version_under1p8 = _nlv < '1.8'
AttributeError: module 'numpy' has no attribute 'version'
I have no idea about how to fix it, what is the problem?My python's version is 3.6
Numpy has dependencies and Anaconda has a history of getting them wrong leading to numpy failing to initialize properly. The AttributeError is most likely caused by numpy initialization failure. This error usually happens when updating numpy or other dependencies that change numpy versions via conda (that's why you can get numpy failing after updating Pandas...)
Example of such failure: https://github.com/ipython/ipyparallel/issues/326
The solution that always works for me is updating to a known working version of numpy. Currently, for me on Windows 10 x64, it is 1.15.1.
Please note it is a problem with Anaconda dependencies rather than numpy itself. Can't provide more specific guidance without details like OS, package versions, etc.

cannot import name ExtendedInterpolation

Interestingly, on my machine (OSX) importing the package hgvs runs smoothly, even though I'm working on python 2.7 (and ExtendedInterpolation is a python 3 function from configparser). As far as what I've gathered, it simply uses a backport of Python 3's configparser module, so it should work anyways if Python 3 is installed.
However, the following error occurs when I try to import the module on a EC2 instace using iPython Notebook.
Any ideas of what may be causing the issue?
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-60-832dbede7fbb> in <module>()
----> 1 import hgvs.location
/usr/local/lib/python2.7/dist-packages/hgvs/hgvs/__init__.py in <module>()
57 import warnings
58
---> 59 from .config import global_config # flake8: noqa; importing symbol
60
61 logger = logging.getLogger(__name__)
/usr/local/lib/python2.7/dist-packages/hgvs/hgvs/config.py in <module>()
22 from __future__ import absolute_import, division, print_function, unicode_literals
23
---> 24 from configparser import ConfigParser, ExtendedInterpolation
25 from copy import copy
26 import logging
ImportError: cannot import name ExtendedInterpolation
According to this the problem is that:
Unfortunately in 0.14.0 they broke the configparser import by introducing their own.
To resolve it, I downgraded the future library:
pip install future==0.13.1

Categories