Pandas giving me an import error for Datautil? - pandas

I am trying to import the pandas module. However, when attempting to run my code, I get the following error:
raise ImportError('dateutil 2.5.0 is the minimum required version')
ImportError: dateutil 2.5.0 is the minimum required version
However, I already have the 2.5.0 verison on my computer, as seen from the following message when attempting to pip install.
Requirement already satisfied: python-dateutil in /Users/nat/Library/Python/3.5/lib/python/site-packages (2.5.0)
Does anyone have any suggestions on what could be the problem?

Try installing below package,
pip install python-dateutil==2.5.0

Related

ModuleNotFoundError: No module named 'pandas' (Problem with Python3.9)

Initially, I ran experiments on python3, which supports Pandas perfectly. Since our lab recently upgraded the server to an RTX 3000 series GPU, it supports Python 3.9, not previous versions. For that, when I ran the tests in python3.9 (python3.9 code file.py), the following error occurred:
ModuleNotFoundError: No module named 'pandas'
Then I ran 'pip install pandas' and found that the requirements had already been met; here's further information:
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pandas in ./.local/lib/python3.6/site-packages (1.1.5)
Requirement already satisfied: pytz>=2017.2 in ./.local/lib/python3.6/site-packages (from pandas) (2021.1)
Requirement already satisfied: python-dateutil>=2.7.3 in ./.local/lib/python3.6/site-packages (from pandas) (2.8.2)
Requirement already satisfied: numpy>=1.15.4 in ./.local/lib/python3.6/site-packages (from pandas) (1.19.5)
Requirement already satisfied: six>=1.5 in ./.local/lib/python3.6/site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
But when I ran the file again, I received the same issue: ModuleNotFoundError: No module named 'pandas'
How can we install solve this issue?
You need to make sure you are running pip with the correct python version. ./.local/lib/python3.6/site-packages in your error indicates that you are still using python3.6.
If you are using IPython, you can type pip install pandas directly in the interactive mode (not in the terminal), which uses the proper Python version then.
In general, I would create a virtual environment using /path/to/python39 -m venv ~/myvenv, then active it using source ~/myvenv/bin/activate and install packages then - especially if using a graphics card you may need different package versions for different projects.
According to my understanding, our lab server supports various Python versions, and I was executing my code files from a directory with a Python version of 3.6, which caused the issue. Therefore, we must either change our project directory to Python 3.9 and install Pandas there or use the following command as instructed here.
python3.9 -m pip install pandas

Python, Pandas datareader and Yahoo Error RemoteDataError: Unable to read URL

I am trying to download historical data from Yahoo using Pandas datareader. This is the code that I normally use:
import pandas_datareader as pdr
df = pdr.get_data_yahoo('SPY')
However, I started receiving this error today: RemoteDataError: Unable to read URL: https://finance.yahoo.com/quote/SPY/history?period1=1467511200&period2=1625277599&interval=1d&frequency=1d&filter=history
Does anyone know how to solve it?
Thank you very much in advance!
This has been answered here already. Since now requires headers, pandas and pandas-datareader must be updated. Other libraries working with pdr might give you issues until gets updated or you modify the part of the code which retreives data.
Have a nice day ;).
pip install --upgrade pandas
pip install --upgrade pandas-datareader
If you are using Colab, run:
!pip install --upgrade pandas-datareader
...
Installing collected packages: pandas-datareader
Attempting uninstall: pandas-datareader
Found existing installation: pandas-datareader 0.9.0
Uninstalling pandas-datareader-0.9.0:
Successfully uninstalled pandas-datareader-0.9.0
Successfully installed pandas-datareader-0.10.0
WARNING: The following packages were previously imported in this runtime:
[pandas_datareader]
You must restart the runtime in order to use newly installed versions.
Go to Runtime -> Restart runtime. Then you can import pandas_datareader and check that it's the right version:
import pandas_datareader
pandas_datareader.__version__ # Should show 0.10.0

ModuleNotFoundError: No module named 'flask_sqlalchemy

I am getting this error when i try to run:
flask db upgrade
from flask_sqlalchemy import SQLAlchemy
ModuleNotFoundError: No module named 'flask_sqlalchemy'
I verified that flask-sqlalchemy is already installed:
Requirement already satisfied: flask-sqlalchemy in ./venv/lib/python3.6/site-packages (2.4.4)
Are you using the correct version of Python? By installing flask_sqlalchemy and using Python3, make sure you install the module by typing pip3 install flask-sqlalchemy, so the module gets installed in Python3 and not another version. If you want to use Python2, make sure using the normal command pip install flask-sqlalchemy.

I want to use pandas2ri in JUPYTER but tzlocal issue?

Everytime I try to import the pandas2ri in jupyter, python interface:
from rpy2.robjects import pandas2ri
I get the following error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-28-cc52694d111a> in <module>()
----> 1 from rpy2.robjects import pandas2ri
/Users/sondosayyash/anaconda/lib/python3.6/site-packages/rpy2/robjects/pandas2ri.py in <module>()
21 import numpy
22 import pytz
---> 23 import tzlocal
24 import warnings
25
ModuleNotFoundError: No module named 'tzlocal'
I tried to use
from dateutil.tz import tzlocal
but that didn't seem to fix the issue.
I've already installed tzlocal and it is on my computer. When I import pandas2ri on ipython, there is no problem.. the problem only occurs when calling in the jupyter environment.
this is the message I get when I try to install tzlocal again:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020.
Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: tzlocal in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (1.5.1)
Requirement already satisfied: pytz in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from tzlocal) (2017.2)
I had a similar issue when running rpy2 in Jupyter. I did not have the package installed previously. I just installed the package and the error went away. You can try installing the package again to see if it helps resolve your issue.
pip install tzlocal
I must add that I am using Python 3.6.8 not 2.7
If using conda:
conda install tzlocal
worked.
I had a similar issue as yours. It turns out that my local lib did not have the tzlocal package. So I installed the package through Anaconda prompt:
pip install tzlocal
And the issue is gone.

Error installing pandas with pip: Could not find a version that satisfies the requirement numpy==1.9.3

I'm trying to install pandas. When I run: pip install pandas in cmd, I get the following error message: Could not find a version that satisfies the requirement numpy==1.9.3. Not sure how to fix this.
It's likely you have a different version of numpy installed, try upgrade numpy first with:
pip install numpy==1.9.3 --upgrade
then run pip install pandas. Also check this github issue. Maybe your python version is not supported.