midwest_blob
midwest_blob

Reputation: 11

Pandas Python Program runs on Python3, 3.8 but not 3.6

Whenever I run the command python3.6 Check.py, I get the following error,

Pandas Error

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/pandas/init.py", line 30, in from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib File "/usr/lib/python3/dist-packages/pandas/_libs/init.py", line 3, in from .tslibs import ( File "/usr/lib/python3/dist-packages/pandas/_libs/tslibs/init.py", line 3, in from .conversion import localize_pydatetime, normalize_date
ModuleNotFoundError: No module named 'pandas._libs.tslibs.conversion'

During handling of the above exception, another exception occurred: Traceback (most recent call last): ​File "Check.py", line 2, in ​import pandas as pd ​File "/usr/lib/python3/dist-packages/pandas/init.py", line 38, in ​"the C extensions first.".format(module) ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' 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 quickly google the error and find this link: No module named 'pandas._libs.tslib'

I uninstall pandas: uninstall message

Found existing installation: pandas 1.3.3 Uninstalling pandas-1.3.3: Would remove: /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages/pandas-1.3.3.dist-info/* /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages/pandas/* Proceed (y/n)? y Successfully uninstalled pandas-1.3.3

I reinstall it: reinstall message

Requirement already satisfied: pandas in /usr/lib/python3/dist-packages (0.25.3)

I upgrade it too: upgrade message

Collecting pandas Using cached pandas-1.3.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (11.5 MB) Requirement already satisfied, skipping upgrade: numpy>=1.17.3 in /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages (from pandas) (1.21.2) Requirement already satisfied, skipping upgrade: pytz>=2017.3 in /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages (from pandas) (2021.1) Requirement already satisfied, skipping upgrade: python-dateutil>=2.7.3 in /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages (from pandas) (2.8.2) Requirement already satisfied, skipping upgrade: six>=1.5 in /u/riker/u97/pmohanty/.local/lib/python3.8/site-packages (from python-dateutil>=2.7.3->pandas) (1.16.0) Installing collected packages: pandas Successfully installed pandas-1.3.3

Despite following the steps my file won't run. Strangely it works for python3, python3.8, but not for python3.6.

python3 --version outputs 3.8.10

python3.6 --version outputs 3.6.9

pip --version outputs pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

I am new to python and pandas and stackoverflow. Any help is appreciated.

PS: I need to get it to work in 3.6 :'(

Upvotes: 1

Views: 4016

Answers (1)

2e0byo
2e0byo

Reputation: 5934

If you really need it to work in python 3.6, you need to install it for python 3.6:

python3.6 -m pip install pandas

See e.g. this article for a discussion of why this works.

Upvotes: 1

Related Questions