Skip to content

DOC: Unable to import pandas on python 3.5.2 #27558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kszucs opened this issue Jul 24, 2019 · 21 comments · Fixed by #27580
Closed

DOC: Unable to import pandas on python 3.5.2 #27558

kszucs opened this issue Jul 24, 2019 · 21 comments · Fixed by #27580

Comments

@kszucs
Copy link

kszucs commented Jul 24, 2019

Code Sample, a copy-pastable example if possible

import pandas

Problem description

Although it seems like a typing issue pandas is still affected, error:

root@ae9a5374fe6d:/buildbot# python -c "import pandas"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/pandas/__init__.py", line 55, in <module>
    from pandas.core.api import (
  File "/usr/local/lib/python3.5/dist-packages/pandas/core/api.py", line 5, in <module>
    from pandas.core.arrays.integer import (
  File "/usr/local/lib/python3.5/dist-packages/pandas/core/arrays/__init__.py", line 1, in <module>
    from .array_ import array  # noqa: F401
  File "/usr/local/lib/python3.5/dist-packages/pandas/core/arrays/array_.py", line 7, in <module>
    from pandas.core.dtypes.common import (
  File "/usr/local/lib/python3.5/dist-packages/pandas/core/dtypes/common.py", line 11, in <module>
    from pandas.core.dtypes.dtypes import (
  File "/usr/local/lib/python3.5/dist-packages/pandas/core/dtypes/dtypes.py", line 53, in <module>
    class Registry:
  File "/usr/local/lib/python3.5/dist-packages/pandas/core/dtypes/dtypes.py", line 84, in Registry
    self, dtype: Union[Type[ExtensionDtype], str]
  File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "/usr/lib/python3.5/typing.py", line 512, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 1077, in __subclasscheck__
    if super().__subclasscheck__(cls):
  File "/usr/lib/python3.5/abc.py", line 225, in __subclasscheck__
    for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument

To reproduce:

$ docker pull ursalab/amd64-ubuntu-16.04-python-3:worker
$ docker run -it ursalab/amd64-ubuntu-16.04-python-3:worker bash
# python -c "import pandas"

Output of pip freeze | grep pandas

pandas==0.25.0
@jreback
Copy link
Contributor

jreback commented Jul 24, 2019

3.5.3 is the minimum on 0.25; see the release notes

@jreback jreback closed this as completed Jul 24, 2019
@kszucs
Copy link
Author

kszucs commented Jul 24, 2019

@jreback Thanks! May I suggest to update the documentation about that https://pandas.pydata.org/pandas-docs/stable/install.html#python-version-support ?

@jreback
Copy link
Contributor

jreback commented Jul 24, 2019

yes that needs updating (and removing the 2.7)

@jreback jreback reopened this Jul 24, 2019
@jreback jreback added this to the 0.25.1 milestone Jul 24, 2019
@jreback jreback changed the title Unable to import pandas on python 3.5.2 DOC: Unable to import pandas on python 3.5.2 Jul 24, 2019
@jreback jreback modified the milestones: 0.25.1, 1.0 Jul 26, 2019
@jorisvandenbossche
Copy link
Member

@kszucs how is pandas being installed? (I don't directly find this profile in the configuration)
As normally this should be catched during installation (see discussion i #27288)

@kszucs
Copy link
Author

kszucs commented Jul 30, 2019

@jorisvandenbossche

FROM ubuntu:16.04

RUN apt-get update -y && \
    apt-get install -y python3 python3-pip
RUN pip3 install pandas

CMD python3 -c "import pandas"
$ docker build -t pandas-py35 -f <the-dockerfile-above> .
$ docker run pandas-py35

@TomAugspurger
Copy link
Contributor

@kszucs that had a warning for me locally

Step 3/4 : RUN pip3 install pandas
 ---> Running in 2181656518ff
Collecting pandas
  Downloading https://files.pythonhosted.org/packages/a7/d9/e03b615e973c2733ff8fd53d95bd3633ecbfa81b5af2f83fe39647c02344/pandas-0.25.0-cp35-cp35m-manylinux1_x86_64.whl (10.3MB)
Collecting python-dateutil>=2.6.1 (from pandas)
  Downloading https://files.pythonhosted.org/packages/41/17/c62faccbfbd163c7f57f3844689e3a78bae1f403648a6afb1d0866d87fbb/python_dateutil-2.8.0-py2.py3-none-any.whl (226kB)
Collecting numpy>=1.13.3 (from pandas)
  Downloading https://files.pythonhosted.org/packages/69/25/eef8d362bd216b11e7d005331a3cca3d19b0aa57569bde680070109b745c/numpy-1.17.0-cp35-cp35m-manylinux1_x86_64.whl (20.2MB)
Collecting pytz>=2017.2 (from pandas)
  Downloading https://files.pythonhosted.org/packages/3d/73/fe30c2daaaa0713420d0382b16fbb761409f532c56bdcc514bf7b6262bb6/pytz-2019.1-py2.py3-none-any.whl (510kB)
Collecting six>=1.5 (from python-dateutil>=2.6.1->pandas)
  Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, numpy, pytz, pandas
Successfully installed numpy-1.17.0 pandas-0.25.0 python-dateutil-2.8.0 pytz-2019.1 six-1.12.0
You are using pip version 8.1.1, however version 19.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

I suspect that with a newer version of pip (RUN pip3 install -U pip setuptools), the build would error.

@kszucs
Copy link
Author

kszucs commented Jul 30, 2019

Probably.

@csbrown
Copy link

csbrown commented Aug 14, 2019

The python3 version in Ubuntu Xenial repos is 3.5.1. This breaks a lot of stuff for a lot of people. Not sure if that means anything to y'all, but I thought you might like to know.

@TomAugspurger
Copy link
Contributor

@csbrown that should be fine. You'll just pull in pandas 0.24.x when you install. Does that not happen?

@csbrown
Copy link

csbrown commented Aug 14, 2019

it pulls pandas 0.25 for me. I pip3 install pandas==0.23 and it works fine.

@csbrown
Copy link

csbrown commented Aug 14, 2019

Just doing a pip3 install pandas and trying to import pandas is what landed me here looking for what went wrong :)

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Aug 14, 2019 via email

@csbrown
Copy link

csbrown commented Aug 14, 2019

scott@gpu-001:~$ sudo apt-get install --only-upgrade python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pip is already the newest version (8.1.1-2ubuntu0.4).
0 upgraded, 0 newly installed, 0 to remove and 280 not upgraded.

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Aug 14, 2019 via email

@csbrown
Copy link

csbrown commented Aug 14, 2019

The workaround is just fine for me. Maybe this info will help someone else though.

quintusdias pushed a commit to quintusdias/pandas_dev that referenced this issue Aug 16, 2019
@ThibaultRouillard
Copy link

If you are using python 3.5.2, using pandas version 0.24.2 works

pip3 uninstall pandas

pip3 install pandas==0.24.2

javierluraschi added a commit to rstudio/pins-r that referenced this issue Oct 21, 2019
@leonjinzhong
Copy link

If you are using python 3.5.2, using pandas version 0.24.2 works

pip3 uninstall pandas

pip3 install pandas==0.24.2

It works. Thanks.

@ngthianhphuong
Copy link

ngthianhphuong commented Apr 24, 2020

I have same issue here in pandas-dev virtual environment. My Python version is 3.8.2.

I'm following the instructions in this link:

https://pandas.pydata.org/docs/dev/development/contributing.html#creating-a-development-environment

python setup.py build_ext --inplace -j 4 throws an error:

C:\Users\Phuong\Anaconda3\envs\pandas-dev\include /Tcpandas/_libs/src/ujson/python/ujson.c /Fobuild\temp.win-amd64-3.8\Release\pandas/_libs/src/ujson/python/ujson.obj -D_GNU_SOURCE error: command 'cl.exe' failed: No such file or directory

I tried: pip install pandas, it works perfectly fine. But import pandas in Python interpreter throws an error:

  File "C:\Users\Phuong\Documents\GIT\pandas\pandas\__init__.py", line 32, in <module>
    from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
  File "C:\Users\Phuong\Documents\GIT\pandas\pandas\_libs\__init__.py", line 13, in <module>
    from pandas._libs.interval import Interval
ModuleNotFoundError: No module named 'pandas._libs.interval'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Phuong\Documents\GIT\pandas\pandas\__init__.py", line 36, in <module>
    raise ImportError(
ImportError: C extension: No module named 'pandas._libs.interval' 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.

Note that in my base environment, pandas installation and import both work fine.

Do you have any idea how to fix this? Thanks.

@TomAugspurger
Copy link
Contributor

@ngthianhphuong https://pandas.pydata.org/docs/dev/development/contributing.html#creating-a-development-environment has the instructions for building pandas from source to contribute to pandas. Are you intending to contribute to pandas? If so, you'll need to install a C compiler to avoid that error: https://pandas.pydata.org/docs/dev/development/contributing.html#installing-a-c-compiler

If not, then I'd recommend just sticking to pip or conda to install pandas.

Make sure you don't have a folder named pandas where you start your interpreter.

@ngthianhphuong
Copy link

Hi @TomAugspurger, thanks for your prompt reply. Yep that's right, I'd like to contribute so want to check first how it works.
The instructions says Build Tools for Visual Studio 2019 is required, which was already installed. I am now on Creating a Python environment step.
The command python setup.py build_ext --inplace -j 4 must be run in pandas directory, am I right?

@TomAugspurger
Copy link
Contributor

Yes, that's correct.

command 'cl.exe' failed: No such file or directory

That indicates you don't have the compiler on your terminals path. It's been a while since I've used windows, but IIRC there's a special command prompt application launcher that sets everything up for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants