0

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 :'(

1 Answers1

0

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.

2e0byo
  • 5,305
  • 1
  • 6
  • 26
  • I get " ModuleNotFoundError: No module named 'distutils.util'" – midwest_blob Sep 29 '21 at 18:40
  • 1
    then your python 3.6 installation is broken, and you need to fix that before installing pandas. You *might* be able to get round it with `python3.6 -m ensurepip`. – 2e0byo Sep 29 '21 at 18:44
  • I will try installing it. But ssh won't let me use sudo commands for installing python3.6. Are there other ways? Sorry I am really new to this – midwest_blob Sep 29 '21 at 19:28
  • ah, so you're sshing into a server. If you can't sudo that's got nothing to do with ssh. Do you run the server? why exactly do you *have* to use python 3.6? AFAIK you don't need root to run ensurepip anyhow, but I could be wrong – 2e0byo Sep 29 '21 at 19:30
  • 1. I ssh into the server. 2. its for an assignment. They want it to run on 3.6 . 3. I tried running ensurepip. This is what I got, ensurepip is disabled in Debian/Ubuntu for the system python. Python modules for the system python are usually handled by dpkg and apt-get. apt-get install python- Install the python-pip package to use pip itself. Using pip together with the system python might have unexpected results for any system installed module, so use it on your own risk, or make sure to only use it in virtual environments." – midwest_blob Sep 29 '21 at 19:44
  • 1
    In that case you have no choice: you have been given the option of a deliberately limited python3.6, or a working 3.8. If you are allowed to use pandas, write for the 3.8 taking care not to use f-strings. In any case this is something to take up with your institution: ask them how they expect you to install packages, and what you are allowed to install. – 2e0byo Sep 29 '21 at 20:01
  • I'd directly ask them. tysm for the continued help. – midwest_blob Sep 29 '21 at 20:07