I'm facing this issue while trying to use pandas package. I have installed numpy 1.9.0 and installed dateutil 2.5.0 using the command
pip install python-dateutil==2.5.0. Still I see this error.
Is there any other way to install dateutil? And this is related only to pandas package
Traceback (most recent call last): import pandas as pd File
"/Users/xyz/Library/Python/2.7/lib/python/site-packages/pandas/init.py",
line 23, in
from pandas.compat.numpy import * File "/Users/xyz/Library/Python/2.7/lib/python/site-packages/pandas/compat/init.py",
line 422, in
raise ImportError('dateutil 2.5.0 is the minimum required version') ImportError: dateutil 2.5.0 is the minimum required version
I had this same issue using the newest pandas version, try downgrading to pandas 0.22.0 which fixed my issue
The issue was resolved by installing python 3.6. There is a version compatibility issue between pandas package and earlier version of Python
Check what code you used to run the program
I first tried running the file with: "python file.py"
but I got an error. so try running the file with
python3 file.py
(put your file name instead of the file)
This fixed the error and I was able to run the file
Related
I am using xlwings for running a macro from Excel to plot histogram using python matplotlib but I get the following error when trying to run the python code to plot the histogram from excel:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\adel.moustafa\dashboard\main.py", line 7, in <module>
from Modules import Plotter
File "c:\users\adel.moustafa\dashboard\Modules\Plotter.py", line 6, in <module>
import matplotlib.pyplot as plt
File "C:\Users\adel.moustafa\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\__init__.py", line 887, in <module>
cbook._get_data_path("matplotlibrc"),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\adel.moustafa\AppData\Local\Programs\Python\Python311\Lib\site-packages\matplotlib\cbook\__init__.py", line 559, in _get_data_path
return Path(matplotlib.get_data_path(), *args)
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'matplotlib' has no attribute 'get_data_path'
This only happens when I try to run the python code from excel using macro, however if run the same code from Pycharm IDE it works fine and no error is produced.
I have looked for this error and what it means and reach the conclusion of that the error source may be due to conflict of matplotlib versions (one installed using conda and the other using pip). so I have completely removed install anaconda distribution using this guide after that I uninstall and reinstall matplotlib using pip but unfortunately that did not solve the problem. so, I continue to search and found similar posts to my case that advice by using a python virtual environment to solve the problem. so, I have done that but also with no result. finally I completely removed python from my system and reinstalled it but that did not solve the problem either. now, I really don't know what else to do or try!. so if any one could help it would much appreciated.
here is the list of packages installed on my machine
Package Version
--------------- --------
contourpy 1.0.7
cycler 0.11.0
fonttools 4.38.0
kiwisolver 1.4.4
matplotlib 3.6.3
numpy 1.24.1
packaging 23.0
pandas 1.5.3
Pillow 9.4.0
pip 22.3.1
pyparsing 3.0.9
python-dateutil 2.8.2
pytz 2022.7.1
pywin32 305
seaborn 0.12.2
setuptools 65.6.3
six 1.16.0
wheel 0.38.4
xlwings 0.28.9
and the python version
Python 3.11.1
finally here is the posts that I looked at.
post1
post2
post3
post4
post5
I am trying to run a python script off the Windows command prompt. The script runs in a server environment which is a tough place to install modules because of our companies firewalls. So It was convenient to use Anaconda 3 which includes python 3.8 and Data engineering modules like Pandas.
The script runs with no issue in Spyder and Visual Studio code, but when I try to run it in the Windows Command line I get the following error:
MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "installservice.py", line 9, in <module>
import pandas as pd
File "C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed. We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "C:\ProgramData\Anaconda3\python.exe"
* The NumPy version is: "1.19.2"
Again the script runs with no issues in my IDEs but not on Windows Command Line. Please help
Try upgrading the pip and then try to uninstall if they are already present in the below order.
pip uninstall pandas
pip uninstall numpy
pip install pandas
pip install numpy
I am not able to import pandas
C:\Users\Yash\Desktop\Python\Twitter Sentimental Analysis>python import.py
Traceback (most recent call last):
File "C:\Users\Yash\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\__init__.py", line 26, in <module>
from pandas._libs import (hashtable as _hashtable,
File "C:\Users\Yash\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\_libs\__init__.py", line 4, in <module>
from .tslib import iNaT, NaT, Timestamp, Timedelta, OutOfBoundsDatetime
ModuleNotFoundError: No module named 'pandas._libs.tslib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "import.py", line 4, in <module>
import pandas as pd
File "C:\Users\Yash\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\__init__.py", line 35, in <module>
"the C extensions first.".format(module))
ImportError: C extension: No module named 'pandas._libs.tslib' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
I tried screwing around but this error stayed the same.
I have updated the modules already along with pip and python!
This is the full traceback of the command.
I am currently using python 3.6.6 (downloaded from the official site)
pip version : 18.1 running on windows 10 laptop!!
I faced a similar issue and solved it by manually uninstalling pandas and then installing pandas using pip. You have mentioned that you have only updated pandas. So I assume you haven't tried re-installing it.
While doing so pandas version in my environment changed from 0.23.4 to 0.24.1
My Environment :
python 3.6.7
pip 18.1
Note : I am also a beginner in Python usage. More experienced users may know a better way.
pip uninstall pandas
pip install pandas
The above steps solved my issues and I am able to import pandas.
I checked the release notes in pandas community and it seems like the dependency on tslib has been removed.
Check section 1.5 in the below link and search for tslib.
http://pandas.pydata.org/pandas-docs/version/0.24/pandas.pdf
I faced the same error and resolved it by calling the following commands:
pip uninstall pandas
pip install pandas
pip3 install --upgrade pandas
I was facing the same error. I tried the above solutions didn't work out. Here what worked for me.
If you have two different python env and trying to run files from different env then first you have to uninstall pandas from both env and install them in the new env.
For example, I have installed python3.6 and python3.9, so first I uninstalled pandas from 3.6
sudo pip3.6 uninstall pandas
I repeated this command serval times until all versions of pandas have uninstalled. after that, I install the pandas in 3.9 using this command
/usr/bin/python3.9 -m pip install pandas
Im trying to run a code for portfolio optimization and i get the following error right on import of pandas.
Traceback (most recent call last):
File "/Users/***/Desktop/Markowitz-master/MarkowitzOpt.py", line 2, in <module>
from pandas import Series, DataFrame
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/__init__.py", line 18, in <module>
raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['pytz', 'dateutil']
I used pip freeze to check all installed packages, and both puts and dateutil are installed.
Any insights would be appreciated!!!
dateutil can get confused with python-dateutil, try the following:
pip install python-dateutil pytz --force-reinstall --upgrade
If you are also using conda you may have to also update the packages in conda.
conda update python-dateutil pytz
This worked for me.
Note: I was getting the error when I attempted to load pandas in IPython for Python 2.7.15. I was not in a conda virtual env but the ipython install that was being loaded came from conda. Updating the packages in conda solved the issue.
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