Am new to progamming and Python, i keep getting the error below when i run my program. Someone advised i should use pip to solve it. But cant pip get installed using the cmd. Though i suceeded using Powershell but still cant make it work. How do i solve this, any tips will go along way. Thanks
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from satmc import satmc
File "C:\Python27\starb_models_grid1\satmc.py", line 3, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 110, in <module>
raise ImportError("matplotlib requires dateutil")
ImportError: matplotlib requires dateutil
Am using version 2.7.3
You need to install various packages to get numpy working correctly.
libsvm-3.17.win32-py2.7
pyparsing-2.0.1.win32-py2.7
python-dateutil-2.2.win32-py2.7
pytz-2013.9.win32-py2.7
six-1.5.2.win32-py2.7
scipy-0.13.3.win32-py2.7
numpy-MKL-1.8.0.win32-py2.7
Matplotlib
Download all the binaries from this link and install and then you will have a working numpy installation.
You're probably looking for:
pip install python-dateutil
The error states that you are missing Dateutil.
This could mean that you did not install Dateutil with pip install python-dateutil or your way to install Python modules. But if you did your pip install and still get the same error it could also mean that DateUtil is installed in a folder where your Python distribution does not expect it.
In my case (Mac OSX) I installed pip with Brew http://brew.sh/. That pip will install the modules in: /usr/local/lib/python2.7/site-packages/
However the standard Mac OSX Python distribution will look for modules in /Library/Python/2.7/site-packages/
Your folders could be different of course, but you can check where Python looks for modules with:
import sys
print sys.path
Check this and see if one of the directories in the list contains the directory where dateutil is installed.
If not add a PYTHONPATH environment variable: Like: PYTHONPATH=/usr/local/lib/python2.7/site-packages/ or the folder where your dateutil is installed
I did pip install python-dateutil, but kept getting the same error. I got past that error by installing from http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-dateutil
Look for the Matplotlib section and install the dependencies you don't have.
Matplotlib is a 2D plotting library.
Requires numpy, dateutil, pytz, pyparsing, six, setuptools, and optionally pillow, pycairo, tornado, wxpython, pyside, pyqt4, ghostscript, miktex, ffmpeg, mencoder, avconv, or imagemagick.
Related
Previously I asked how to install openbabel for macos here. Now I also need to install the openbabel python wrapper pybel. I tried pip install pybel and it was installed. Then, while I was following the tutorial,
import openbabel
import pybel
mymol = pybel.readstring("smi", "CCCC")
I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: module 'pybel' has no attribute 'readstring'
It turns out other people had similar issues and in fact I found in the mailing list that, I quote
'I guess you installed pybel via pip install pybel, which is the
"wrong" pybel'
Then they give a solution which is pip install openbabel, which is not possible for macos.
A solution is to use conda to install openbabel but I am not using conda and I would like to keep it that way so I am looking for a solution which does not require conda.
I found the solution, you can brew install open-babel and then give the path to homebrewed library of python site-packages. For me the following works:
import sys
sys.path.append('/usr/local/lib/python3.8/site-packages')
Then you can
import openbabel
from openbabel import pybel
and so on.
I have exactly the same problem. It works with the following code:
from openbabel import pybel
mymol = pybel.readstring("smi","CCN(CC)CC")
mymol
I was able to run all scripts successfully which is using pandas , but suddenly all my PANDAS SCRIPTS are giving this error :
Traceback (most recent call last):
File "data_visulaization.py", line 5, in
import pandas as pd
File "/usr/lib64/python2.7/site-packages/pandas/init.py", line 18,
in
raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']
Recently i have not installed or updated any new things.
Does anyone have a solution for this?
I uninstalled pandas and numpy and re-installed them but still facing the same issue.
I got this issue on Rasberry PI and found that the root cause was missing library:
import numpy
...
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory
Then it takes few minute to google the required library source:
sudo apt-get install libatlas-base-dev
I have not checked the solution on any other Linux-es but likely the same method should be applicable. So try to import the faulty library first and see what is missing.
I faced the exact same error and found that I had created a file named 'random.pyc' by mistake in the same directory as that of my PyCharm environment
ayush#ayush-VirtualBox:~/PycharmProjects/untitled$ where "untitled" refers to my project directory. I deleted it and everything fells into place. Hope this helps !
The reason for this was numpy Imports another file called Random by default for building its own dependencies and it mistook my 'random.pyc' for it and replaced it.
I had the same error. Fixed with the following:
python3 -m pip uninstall numpy
python3 -m pip install numpy==1.14.0
use"conda install numpy" in cmd-window if you used Anaconda in your machine. I had encount this problem also and I resolved it by this. May it can help U.
I found the solution , the actual problem is if any of your recent python scripts have generated ".pyc" extension file this error will occur .
solution is to delete those files that's all.
If you are using packages options and it contains pandas or some package depends numpy, you should add required dependencies to the packages.
pip uninstall numpy
pip install numpy
It works
This error will occur when multiple versions of numpy are installed. Check to make sure you only have one version of numpy installed. You can make a test file to check this if you don't want to look through the directories:
import numpy
print("Numpy imported")
If you get an error saying that multiple versions of numpy were detected, then you have multiple versions of numpy installed.
You can fix this by repeatedly calling (not just once)
pip uninstall numpy
until all versions are uninstalled and then use
pip install numpy
to get only the latest version.
try uninstalling pandas and numpy:
pip uninstall pandas
pip uninstall numpy
and install them back:
pip install pandas
pip install numpy
I am trying to run the following simple code
import scipy
scipy.test()
But I am getting the following error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 586, in runfile
execfile(filename, namespace)
File "C:/Users/Mustafa/Documents/My Python Code/SpectralGraphAnalysis/main.py", line 8, in <module>
import scipy
File "C:\Python27\lib\site-packages\scipy\__init__.py", line 61, in <module>
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
ImportError: cannot import name NUMPY_MKL
I am using python 2.7 under windows 10.
I have installed scipy but that does not seem to solve the problem
Any help is appreciated.
If you look at the line which is causing the error, you'll see this:
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
This line comment states the dependency as numpy+mkl (numpy with Intel Math Kernel Library). This means that you've installed the numpy by pip, but the scipy was installed by precompiled archive, which expects numpy+mkl.
This problem can be easy solved by installation for numpy+mkl from whl file from here.
Reinstall numpy-1.11.0_XXX.whl (for your Python) from www.lfd.uci.edu/~gohlke/pythonlibs. This file has the same name and version if compare with the variant downloaded by me earlier 29.03.2016, but its size and content differ from old variant. After re-installation error disappeared.
Second option - return back to scipy 0.17.0 from 0.17.1
P.S. I use Windows 64-bit version of Python 3.5.1, so can't guarantee that numpy for Python 2.7 is already corrected.
I'm not sure if this is a good solution but it removed the error.
I commented out the line:
from numpy._distributor_init import NUMPY_MKL
and it worked. Not sure if this will cause other features to break though
I had the same problem while installing gensim on windows. Gensim is dependent on scipy and scipy on numpy. Making all three work is real pain. It took me a lot of time to make all there work on same time.
Solution:
If you are using windows make sure you install numpy+mkl instead of just numpy.
If you have already installed scipy and numpy, uninstall then using "pip uninstall scipy" and "pip uninstall numpy"
Then download numpy-1.13.1+mkl-cp34-cp34m-win32.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
and install using pip install numpy-1.13.1+mkl-cp34-cp34m-win32.wh
Note: in cp34-cp34m 34 represent the version of python you are using, so download the relevant version.
Now download scipy from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy (appropriate version for your python and system)
and install using "pip install scipy‑0.19.1‑cp34‑cp34m‑win32.whl"
Your numpy and Scipy both should work now.
These binaries by Christoph Gohlke makes it very easy to install python packages on windows. But make sure you download all the dependent packages from there.
I don't have enough reputation to comment but I want to add, that the cp number of the .whl file stands for your python version.
cp35 -> Python 3.5.x
cp36 -> Python 3.6.x
cp37 -> Python 3.7.x
I think it's pretty obvious but still I wasted almost an hour because of this and maybe other people struggle with that, too.
So for me worked version cp36 that I downloaded here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
since I am using Python 3.6.8.
Then I uninstalled numpy:
pip uninstall numpy
Then I installed numpy+mkl:
pip install <destination of your .whl file>
The reason for the error is you upgraded your numpy library of which there are some functionalities from scipy that are required by the current version for it to run which may not be found in scipy. Just upgrade your scipy library using python -m pip install scipy --upgrade. I was facing the same error and this solution worked on my python 3.5.
From your log its clear that numpy package is missing. As mention in the PyPI package:
The SciPy library depends on NumPy, which provides convenient and fast N-dimensional array manipulation.
So, try installing numpy package for python as you did with scipy.
I recently got the same error when trying to load scipy in jupyter (python3.x, win10), although just having upgraded to numpy-1.13.3+mkl through pip.
The solution was to simply upgrade the scipy package (from v0.19 to v1.0.0).
yes,Just reinstall numpy,it works.
At some point in the last few days, Matplotlib stopped working for me on OS X. Here's the error I get when trying to import matplotlib:
Traceback (most recent call last):
File "/my/path/to/script/my_script.py", line 15, in <module>
import matplotlib.pyplot as plt
File "/Library/Python/2.7/site-packages/matplotlib/pyplot.py", line 34, in <module>
from matplotlib.figure import Figure, figaspect
File "/Library/Python/2.7/site-packages/matplotlib/figure.py", line 40, in <module>
from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
File "/Library/Python/2.7/site-packages/matplotlib/axes/__init__.py", line 4, in <module>
from ._subplots import *
File "/Library/Python/2.7/site-packages/matplotlib/axes/_subplots.py", line 10, in <module>
from matplotlib.axes._axes import Axes
File "/Library/Python/2.7/site-packages/matplotlib/axes/_axes.py", line 22, in <module>
import matplotlib.dates as _ # <-registers a date unit converter
File "/Library/Python/2.7/site-packages/matplotlib/dates.py", line 126, in <module>
from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
File "/Library/Python/2.7/site-packages/dateutil/rrule.py", line 14, in <module>
from six.moves import _thread
ImportError: cannot import name _thread
The only system change I can think of was the Apple-forced NTP update and maybe some permission changes I did in /usr/local to get Brew working again.
I tried reinstalling both Matplotlib and Python-dateutil via Pip, but this did not help. Also tried a reboot. I'm running Python 2.7.6, which is located in /usr/bin/python. I'm running Yosemite (OS X 10.10.1).
sudo pip uninstall python-dateutil
sudo pip install python-dateutil==2.2
I had the same error message this afternoon as well, although I did recently upgrade to Yosemite. I'm not totally sure I understand why reverting dateutil to a previous version works for me, but since running the above I'm having no trouble (I generally use pyplot inline in an ipython notebook).
This problem is fixed in the latest six and dateutil versions. However, in OS X, even if you update your six to the latest version, you might not actually update it correctly. This is what happened to me:
After doing a pip2 install six -U, the new six module was installed in /Library/Python/2.7/site-packages/. However, when I loaded six in a python 2.7 terminal, and checked its path, this is what I got:
import six
print six.__file__
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.pyc
So, python was using an old version of six, which I removed by typing:
rm -rf /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six.*
This fixed this issue for me.
Installing the python-dateutil==2.2 did not work for me.
But a quick-and-dirty workaround did work! I replace six.py in python 2.7 with the six.py from python 3.4 (virtualenv). Since, I have the problem in 2.7 but not 3.4.
UPDATE
I had the same problem again after reinstalling python (and after upgrading to El Capitan). Un-obvious thing is that this error occurs only in the IPython shell and notebook (when I do import matplotlib.pyplot as plt) but works fine from a Python shell.
So a better solution (that did work in my case) without a dirty work-around is to force install both six and ipython. Here is what I did to have this fixed :
$ pip install --ignore-installed six
$ pip install --ignore-installed ipython
It is possible that you have a perfectly installed version of any packages you have installed, but the version used by default is not the one you want. You can see the list of paths that python search from in order to find its packages as follows:
>>> import sys
>>> sys.path
In order to let python search first the most updated version of certain package, instead of removing the system version, what can be done is to set the system variable PYTHONPATH in the ~/.bash_profile (or ~/.bashrc if linux) config file to the path where the new packages are installed:
export PYTHONPATH=/Library/Python/2.7/site-packages
An alternative is to modify the python path inside your python script by adding the path at the beginning of the path list:
import sys
sys.path.insert(1,'/Library/Python/2.7/site-packages')
This needs to be done for every script you need a certain package version. You might want for some reason use an older version that you have installed.
BTW all my installations with easy_install, or pip, or from sources go to /Library/Python/2.7/site-packages
This worked en EL Capitan, and now also in macOS Sierra (10.12.2)
I have installed (with lots of troubles) scikits.audiolab for making sounds out of data. Now when I type:
import scikits.audiolab I get the following error
>>> import scikits.audiolab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.7-intel.egg/scikits/audiolab/__init__.py", line 25, in <module>
from pysndfile import formatinfo, sndfile
File "/Library/Python/2.7/site-packages/scikits.audiolab-0.11.0-py2.7-macosx-10.7-intel.egg/scikits/audiolab/pysndfile/__init__.py", line 1, in <module>
from _sndfile import Sndfile, Format, available_file_formats, \
File "numpy.pxd", line 30, in scikits.audiolab.pysndfile._sndfile (/private/tmp/easy_install-gKE3i5/scikits.audiolab-0.11.0/scikits/audiolab/pysndfile/_sndfile.c:9632)
ValueError: numpy.dtype does not appear to be the correct type object
How do I fix this?
Any alternative package that can do the job?
I had the same issue and for me it was caused by installing another (more recent) version of NumPy.
Check if you have different versions of NumPy installed and try switching back to an older one. For my part: I had a system-wide installation of Python and common modules like NumPy, which I couldn't touch because I'm not admin on that system. So when I installed some other library locally (in ~/.local/lib/python2.7/) it would also install more recent versions of SciPy and NumPy and put them into that local folder. And when importing the module it would draw from the local directory first before looking at the system-wide libraries which were working fine before with scikits.audiolab. So for me it was solved by
pip uninstall numy && pip uninstall scipy because that only deleted the newer local versions of numpy.
But more specific to your case, here is a tutorial how (on a Mac) to switch to a certain version of NumPy:
multiple numpy version on Mac OS X
The NumPy version I found working for my scikits.audiolab is 1.6.1
>>> import numpy
>>> numpy.version.version
'1.6.1'
Hope that helps. :)
Maybe you installed/upgraded numpy after installing talkbox. Try running this command:
pip install --upgrade --force-reinstall scikits.talkbox
As suggested here:
https://github.com/ppwwyyxx/speaker-recognition/issues/13