pandas_datareader not working in jupyter-notebook (Anaconda) - python-3.x

ModuleNotFoundError Traceback (most recent call last)
in ()
3 from matplotlib import style
4 import pandas as pd
----> 5 import pandas_datareader.data as web
6
7 style.use('ggplot')
ModuleNotFoundError: No module named 'pandas_datareader'

data reader gotta be installed separetly.
if using anacoda, try:
conda install -c https://conda.anaconda.org/anaconda pandas-datareader

Related

importing chart packages in jupyter lab notebook

I'm trying to generate a chart in online jupyter lab notebook and it is not allowing by throwing errors. Is it possible to do it there?
Thanks
[Updated the code and error]
import pandas as pd
import plotly.express as px
leads to the below error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[28], line 2
1 import pandas as pd
----> 2 import plotly.express as px
ModuleNotFoundError: No module named 'plotly'
If you want to use package in jupyter notebook,
you should
install package by this line
!pip install package-name
then add new block to write code
import it in code
import package-name
(for someone if finding this question)

onnxruntime: cannot import name 'get_all_providers'

Trying to import onnxruntime in a Jupiter notebook with python 3.6.3 on macOS.
I get the following error on import:
import onnxruntime
ImportError
Traceback (most recent call last)
<ipython-input-4-df664b79ebd4> in <module>
----> 1 import onnxruntime
2
~/.virtualenvs/3.6nlp/lib/python3.6/site-packages/onnxruntime/__init__.py in <module>
11 __author__ = "Microsoft"
12
---> 13 from onnxruntime.capi._pybind_state import get_all_providers, get_available_providers, get_device, set_seed, \
14 RunOptions, SessionOptions, set_default_logger_severity, NodeArg, ModelMetadata, GraphOptimizationLevel, \
15 ExecutionMode, OrtDevice, SessionIOBinding
ImportError: cannot import name 'get_all_providers'
I have looked at similar questions such as this
but haven't found the answer that works for me.
Any suggestions? Thanks!!
It turns out the issue is with libomp not being installed. If you run into this problem you can solve it by running
brew install libomp
Hope this helps if you get stuck like me

Python module incompatibilities

I have just installed gdal into my Python3 root environment using conda:
conda install -c conda-forge gdal
Installation went fine with the usual updates of some dependencies. Now returning to some of my scripts, both netCDF4 and mpl_toolkits.basemap have stopped working. These are the errors I get:
from netCDF4 import Dataset
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-09694a7f0e01> in <module>()
----> 1 from netCDF4 import Dataset
2 import numpy as np
3 import matplotlib.pyplot as plt
4 from scipy.interpolate import griddata
5 from mpl_toolkits.basemap import Basemap
/anaconda3/lib/python3.6/site-packages/netCDF4/__init__.py in <module>()
1 # init for netCDF4. package
2 # Docstring comes from extension module _netCDF4.
----> 3 from ._netCDF4 import *
4 # Need explicit imports for names beginning with underscores
5 from ._netCDF4 import __doc__, __pdoc__
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/netCDF4/_netCDF4.cpython-36m-darwin.so, 2): Library not loaded: #rpath/libhdf5.101.dylib
Referenced from: /anaconda3/lib/python3.6/site-packages/netCDF4/_netCDF4.cpython-36m-darwin.so
Reason: image not found
from mpl_toolkits.basemap import Basemap
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-8-5fb601138328> in <module>()
3 import matplotlib.pyplot as plt
4 from scipy.interpolate import griddata
----> 5 from mpl_toolkits.basemap import Basemap
6 import numpy.ma as ma
7 import glob
/anaconda3/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py in <module>()
35 import numpy as np
36 import numpy.ma as ma
---> 37 import _geoslib
38 import functools
39
ImportError: dlopen(/anaconda3/lib/python3.6/site-packages/_geoslib.so, 2): Library not loaded: #rpath/libgeos-3.5.0.dylib
Referenced from: /anaconda3/lib/python3.6/site-packages/_geoslib.so
Reason: image not found
I have no idea what these errors mean, since those paths do exist. What is most baffling is that the netCDF4 and mpl_toolkits modules did not change (i.e. were not updated/downgraded) with the installation of gdal, so why now are they failing?
I'm at the end of my tether with problems like this. Fortunately I made a copy of my Python root directory before attempting this installation so I can now revert back to it (I've been here many times before).
I know about working in separate conda environments, but am I seriously supposed to install a new environment every time I want to use a new Python module? This not only takes up a lot of harddrive space but most inconveniently means adding new functionality to old codes is impossible (I want to use GDAL to plot some geotiffs using Basemap, which now does not work!).
I cannot imagine proficient Python users battling with these issues - so what am I doing wrong?

import Axes3D issues

I'm using python 3.5 and i tried to import Axes3D from mpl_toolkitd.mplot3d but unfortunately i get this error:
In [1]: from mpl_toolkits.mplot3d import Axes3D
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-357f877dbd2b> in <module>()
----> 1 from mpl_toolkits.mplot3d import Axes3D
/usr/lib/python3/dist-packages/mpl_toolkits/mplot3d/__init__.py in <module>()
2 unicode_literals)
3
----> 4 from matplotlib.externals import six
5
6 from .axes3d import Axes3D
ImportError: No module named 'matplotlib.externals'
This might be arising due to duplicate installation of matplotlib in your system.
Usually pip installs all external packages to:
/usr/local/lib/python3.5/dist-packages/matplotlib
On the other hand, apt-get installs your packages in :
/usr/lib/python3/dist-packages/
Therefore, one way to resolve this would be try following (in order):
sudo apt-get remove python3-matplotlib
sudo pip3 install matplotib.

import boost in python3.5

I use
apt-get install libboost-all-dev
But when I import boost with python3, I get some errors
In [1]: import boost
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-df3240a4d6cf> in <module>()
----> 1 import boost
/usr/lib/python3/dist-packages/boost/__init__.py in <module>()
7 sys.setdlopenflags(flags)
8 else:
----> 9 import mpi
10
ImportError: No module named 'mpi'
I try to use pip3 to install the module mpi, but it seems that there has no module named mpi.
By the way, boost works well in python2.7.
What should I do?

Resources