I tried to import matplotlib and pandas, like this (but separately):
import matplotlib.pyplot
import pandas
but each time there was an error. When i imported pandas, it said
Traceback (most recent call last):
File "<pyshell#36>", line 1, in <module>
import pandas
File "C:\Users\bobby\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandas\__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "C:\Users\bobby\AppData\Local\Programs\Python\Python35-32\lib\site-packages\pandas\compat\__init__.py", line 439, in <module>
from dateutil import parser as _date_parser
File "C:\Users\bobby\AppData\Local\Programs\Python\Python35-32\lib\site-packages\dateutil\parser\__init__.py", line 2, in <module>
from ._parser import parse, parser, parserinfo
File "C:\Users\bobby\AppData\Local\Programs\Python\Python35-32\lib\site-packages\dateutil\parser\_parser.py", line 43, in <module>
from six import binary_type, integer_types, text_type
ImportError: cannot import name 'binary_type'
so I went on command prompt (windows) and tried pip install --upgrade pandas and pip install binary_type, but neither of them worked.
When I imported matplotlib, it said
Traceback (most recent call last):
File "<pyshell#40>", line 1, in <module>
import matplotlib.pyplot
File "C:\Users\bobby\AppData\Local\Programs\Python\Python35-32\lib\site-packages\matplotlib\__init__.py", line 127, in <module>
from . import cbook
File "C:\Users\bobby\AppData\Local\Programs\Python\Python35-32\lib\site-packages\matplotlib\cbook\__init__.py", line 12, in <module>
from six.moves import xrange, zip
ImportError: No module named 'six.moves'; 'six' is not a package
so like before I did pip install --upgrade six , pip install six, and pip install six.move, but none of these work.
What should I do so that both of these modules work?
Related
I am an amateur programmer. I am trying to use:
import thinkdsp as dsp
import thinkplot as plt
I have installed the pip install thinkx module but I keep getting that error and I don't understand why. I will leave what the console shows down below:
Traceback (most recent call last):
File "Karaokemaker1.py", line 1, in <module>
import thinkdsp as dsp
File "C:\Users\keigo\anaconda3\lib\site-packages\thinkdsp.py", line 17, in <module>
import scipy.stats
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\stats\__init__.py", line 384, in <module>
from .stats import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\stats\stats.py", line 185, in <module>
from . import distributions
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\stats\distributions.py", line 10, in <module>
from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous,
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 25, in <module>
from scipy import optimize
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\optimize\__init__.py", line 390, in <module>
from ._minimize import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\optimize\_minimize.py", line 30, in <module>
from ._trustregion_constr import _minimize_trustregion_constr
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\optimize\_trustregion_constr\__init__.py", line 4, in <module>
from .minimize_trustregion_constr import _minimize_trustregion_constr
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\optimize\_trustregion_constr\minimize_trustregion_constr.py", line 4, in <module>
from scipy.sparse.linalg import LinearOperator
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py", line 116, in <module>
from .eigen import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py", line 11, in <module>
from .arpack import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py", line 22, in <module>
from .arpack import *
File "C:\Users\keigo\anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py", line 45, in <module>
from . import _arpack
ImportError: DLL load failed: The specified procedure could not be found.
I assumed the issue was with the scipy because all the following errors come from that module. I checked and I have everything installed properly for the scipy module.
Please help! Thank you!
Run any command prompt you are using as administrator and then run pip install lib_name --force-reinstall
Try using these two commands they will help you:
conda remove --force scipy
And:
pip install scipy
Hello I had the same issue than you. Depend on wich version of python you use you should choose a version thinkx. I recommend you to go on the website of thinkx and check out for past udapte. In my case that was with matplotlib 3.3.1 for python 3.7. I went in git bash and used
pip install matplotlib==3.0.1
and everything worked. I had the same issue with seaborn and it worked.
I just did a conda install of a few packages to follow a tutorial, and now I can't even import pandas.
I installed these:
fake-factory==0.7.2
Faker==0.7.3
pytz==2016.7
tzlocal==1.3.0
And now I get this:
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\__init__.py", line 42, in <module>
from pandas.core.api import *
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\api.py", line 7, in <module>
from pandas.core.arrays.integer import (
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\__init__.py", line 2, in <module>
from .base import (ExtensionArray, # noqa
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\arrays\base.py", line 21, in <module>
from pandas.core import ops
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\ops\__init__.py", line 21, in <module>
from pandas.core.construction import extract_array
File "C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\construction.py", line 18, in <module>
from pandas.core.dtypes.base import ExtensionDtype, registry
ImportError: cannot import name 'registry' from 'pandas.core.dtypes.base' (C:\ProgramData\Anaconda3\envs\ariel\lib\site-packages\pandas\core\dtypes\base.py)
I tried doing a conda update pandas, but to no avail.
I also just installed luigi, not quite sure when it broke as I installed all the additional packages in one go.
Updated version of pandas package using pip3
try this in python3
pip3 install --upgrade pandas
Try updating pandas package in Anaconda:
conda install pandas=1.1.4
If no luck, try updating all packages:
conda update --all
Worked in my case.
So I am trying to install zipline and zipline live. I have installed all of the main packages needed for this, and when I do pip install zipline I get no errors. But then when I go into python and do import zipline I get the error:
>>> import zipline
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\zipline\__init__.py", line 20, in <module>
from . import data
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\zipline\data\__init__.py", line 1, in <module>
from . import loader
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\zipline\data\loader.py", line 20, in <module>
from pandas_datareader.data import DataReader
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas_datareader\__init__.py", line 2, in <module>
from .data import (
File "C:\Users\Benito\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas_datareader\data.py", line 9, in <module>
from pandas.util._decorators import deprecate_kwarg
ModuleNotFoundError: No module named 'pandas.util._decorators'
I have tired pip install pandas.util._decorators but this has not worked. I also tried changing to a more up-to-date pandas, but zipline and zipline live do not support this . Right now I have pandas 0.18.1
I have installed the whl files for fiona, shapely, gdal, rtree and pyproj. Geopandas is also installed via pip install. But I get the following error when importing it:
import geopandas
Traceback (most recent call last):
File "<ipython-input-14-c9ee6bd24dbc>", line 1, in <module>
import geopandas
File "C:\ProgramData\Anaconda3\lib\site-packages\geopandas\__init__.py", line 1, in <module>
from geopandas.geoseries import GeoSeries
File "C:\ProgramData\Anaconda3\lib\site-packages\geopandas\geoseries.py", line 12, in <module>
from geopandas.base import GeoPandasBase, _series_unary_op, _CoordinateIndexer
File "C:\ProgramData\Anaconda3\lib\site-packages\geopandas\base.py", line 14, in <module>
from rtree.core import RTreeError
File "C:\ProgramData\Anaconda3\lib\site-packages\rtree\__init__.py", line 1, in <module>
from .index import Rtree
File "C:\ProgramData\Anaconda3\lib\site-packages\rtree\index.py", line 5, in <module>
from . import core
File "C:\ProgramData\Anaconda3\lib\site-packages\rtree\core.py", line 116, in <module>
raise OSError("could not find or load spatialindex_c.dll")
OSError: could not find or load spatialindex_c.dll
and the following error as well:
import fiona
Traceback (most recent call last):
File "<ipython-input-16-cc872b235141>", line 1, in <module>
import fiona
File "C:\ProgramData\Anaconda3\lib\site-packages\fiona\__init__.py", line 77, in <module>
from fiona.collection import Collection, BytesCollection, vsi_path
File "C:\ProgramData\Anaconda3\lib\site-packages\fiona\collection.py", line 9, in <module>
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
File "fiona\ogrext.pyx", line 25, in init fiona.ogrext
ImportError: cannot import name compat
Can somebody please help me here?
I'm not being able to figure out how to fix this issue. Thanks and regards.
You could try the installation with conda instead of pip.
conda install -c conda-forge cenpy
See the CenPy documentation: https://pypi.org/project/cenpy/
You don't need to separately install geopandas and Rtree if you use conda.
The problem is likely a configuration issue, because getting the installation correct on Macs seems to be tricky. I'm running Mavericks and matplotlib 1.4.x, yet when I open a Python 2.7.5 shell and import pylib, I get this error:
>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/pylab.py", line 230, in <module>
import matplotlib.finance
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/finance.py", line 38, in <module>
from matplotlib.collections import LineCollection, PolyCollection
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/backend_bases.py", line 55, in <module>
import matplotlib.textpath as textpath
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/mathtext.py", line 64, in <module>
import matplotlib._png as _png
ImportError: dlopen(/Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/_png.so, 2): Library not loaded: /usr/local/lib/libpng15.15.dylib
Referenced from: /Library/Python/2.7/site-packages/matplotlib-1.4.x-py2.7-macosx-10.9-intel.egg/matplotlib/_png.so
Reason: image not found
I have libpng16 installed, but not libpng15.
I saw a hardcoded reference to libpng15 in _png.so.
Uninstall and install of matplotlib fixed the issue for me.
You can always moke it by generating a soft link like this
sudo ln -s /opt/X11/lib/libpng.dylib /usr/local/lib/libpng15.15.dylib
Not the cleaner solution but I haven't figure out why matplotlib stubbornly asks specifically for libpng15 and not any 15 or greater.