question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

importing pandas breaks after successfully installing pandas with pip

See original GitHub issue

Code Sample, a copy-pastable example if possible

> docker run --tty --interactive --rm python:2.7.12-alpine ash
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
v3.4.6-150-gf952adf [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.6-83-g67e50bc [http://dl-cdn.alpinelinux.org/alpine/v3.4/community]
OK: 5983 distinct packages available
/ # apk add cython g++ musl-dev
(1/21) Upgrading musl (1.1.14-r12 -> 1.1.14-r14)
(2/21) Installing libffi (3.2.1-r2)
(3/21) Installing python (2.7.12-r0)
(4/21) Installing cython (0.24-r1)
(5/21) Installing libgcc (5.3.0-r0)
(6/21) Installing libstdc++ (5.3.0-r0)
(7/21) Installing binutils-libs (2.26-r1)
(8/21) Installing binutils (2.26-r1)
(9/21) Installing gmp (6.1.0-r0)
(10/21) Installing isl (0.14.1-r0)
(11/21) Installing libgomp (5.3.0-r0)
(12/21) Installing libatomic (5.3.0-r0)
(13/21) Installing pkgconf (0.9.12-r0)
(14/21) Installing pkgconfig (0.25-r1)
(15/21) Installing mpfr3 (3.1.2-r0)
(16/21) Installing mpc1 (1.0.3-r0)
(17/21) Installing gcc (5.3.0-r0)
(18/21) Installing musl-dev (1.1.14-r14)
(19/21) Installing libc-dev (0.7-r0)
(20/21) Installing g++ (5.3.0-r0)
(21/21) Upgrading musl-utils (1.1.14-r12 -> 1.1.14-r14)
Executing busybox-1.24.2-r11.trigger
OK: 230 MiB in 51 packages
/ # ln -s locale.h /usr/include/xlocale.h
/ # pip install numpy==1.11.3 pandas==0.20.2
Collecting numpy==1.11.3
  Downloading numpy-1.11.3.zip (4.7MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4.7MB 242kB/s 
Collecting pandas==0.20.2
  Downloading pandas-0.20.2.tar.gz (10.3MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 10.3MB 124kB/s 
Collecting python-dateutil (from pandas==0.20.2)
  Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 194kB 994kB/s 
Collecting pytz>=2011k (from pandas==0.20.2)
  Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 491kB 874kB/s 
Collecting six>=1.5 (from python-dateutil->pandas==0.20.2)
  Downloading six-1.10.0-py2.py3-none-any.whl
Building wheels for collected packages: numpy, pandas
  Running setup.py bdist_wheel for numpy ... done
  Stored in directory: /root/.cache/pip/wheels/8f/d6/97/4cc26777ee05997164e480e2e5de2c9e9c4e32dfe325ea5bd6
  Running setup.py bdist_wheel for pandas ... done
  Stored in directory: /root/.cache/pip/wheels/fc/fd/0a/5857e8bee7d5cc3ca22228fb7ab5efa43be57c0f9103e54098
Successfully built numpy pandas
Installing collected packages: numpy, six, python-dateutil, pytz, pandas
Successfully installed numpy-1.11.3 pandas-0.20.2 python-dateutil-2.6.0 pytz-2017.2 six-1.10.0
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
/ # python -c "import pandas"
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pandas/__init__.py", line 35, in <module>
    "the C extensions first.".format(module))
ImportError: C extension: umpy.core.multiarray failed to import 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.

Problem description

Installing Pandas with pip is successful, but import pandas breaks.

If I issue two separate pip install commands, one for numpy and one for pandas, it works:

> docker run --tty --interactive --rm python:2.7.12-alpine ash
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/community/x86_64/APKINDEX.tar.gz
v3.4.6-150-gf952adf [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.6-83-g67e50bc [http://dl-cdn.alpinelinux.org/alpine/v3.4/community]
OK: 5983 distinct packages available
/ # apk add cython g++ musl-dev
(1/21) Upgrading musl (1.1.14-r12 -> 1.1.14-r14)
(2/21) Installing libffi (3.2.1-r2)
(3/21) Installing python (2.7.12-r0)
(4/21) Installing cython (0.24-r1)
(5/21) Installing libgcc (5.3.0-r0)
(6/21) Installing libstdc++ (5.3.0-r0)
(7/21) Installing binutils-libs (2.26-r1)
(8/21) Installing binutils (2.26-r1)
(9/21) Installing gmp (6.1.0-r0)
(10/21) Installing isl (0.14.1-r0)
(11/21) Installing libgomp (5.3.0-r0)
(12/21) Installing libatomic (5.3.0-r0)
(13/21) Installing pkgconf (0.9.12-r0)
(14/21) Installing pkgconfig (0.25-r1)
(15/21) Installing mpfr3 (3.1.2-r0)
(16/21) Installing mpc1 (1.0.3-r0)
(17/21) Installing gcc (5.3.0-r0)
(18/21) Installing musl-dev (1.1.14-r14)
(19/21) Installing libc-dev (0.7-r0)
(20/21) Installing g++ (5.3.0-r0)
(21/21) Upgrading musl-utils (1.1.14-r12 -> 1.1.14-r14)
Executing busybox-1.24.2-r11.trigger
OK: 230 MiB in 51 packages
/ # ln -s locale.h /usr/include/xlocale.h
/ # pip install numpy==1.11.3 
Collecting numpy==1.11.3
  Downloading numpy-1.11.3.zip (4.7MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4.7MB 221kB/s 
Building wheels for collected packages: numpy
  Running setup.py bdist_wheel for numpy ... done
  Stored in directory: /root/.cache/pip/wheels/8f/d6/97/4cc26777ee05997164e480e2e5de2c9e9c4e32dfe325ea5bd6
Successfully built numpy
Installing collected packages: numpy
Successfully installed numpy-1.11.3
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
/ # pip install pandas==0.20.2
Collecting pandas==0.20.2
  Downloading pandas-0.20.2.tar.gz (10.3MB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 10.3MB 125kB/s 
Collecting python-dateutil (from pandas==0.20.2)
  Downloading python_dateutil-2.6.0-py2.py3-none-any.whl (194kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 194kB 787kB/s 
Collecting pytz>=2011k (from pandas==0.20.2)
  Downloading pytz-2017.2-py2.py3-none-any.whl (484kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 491kB 1.0MB/s 
Requirement already satisfied (use --upgrade to upgrade): numpy>=1.7.0 in /usr/local/lib/python2.7/site-packages (from pandas==0.20.2)
Collecting six>=1.5 (from python-dateutil->pandas==0.20.2)
  Downloading six-1.10.0-py2.py3-none-any.whl
Building wheels for collected packages: pandas
  Running setup.py bdist_wheel for pandas ... done
  Stored in directory: /root/.cache/pip/wheels/fc/fd/0a/5857e8bee7d5cc3ca22228fb7ab5efa43be57c0f9103e54098
Successfully built pandas
Installing collected packages: six, python-dateutil, pytz, pandas
Successfully installed pandas-0.20.2 python-dateutil-2.6.0 pytz-2017.2 six-1.10.0
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
/ # python -c "import pandas"

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:46 (29 by maintainers)

github_iconTop GitHub Comments

3reactions
jorisvandenbosschecommented, Nov 27, 2017

@jlbooker opened an issue to track this here: https://github.com/pandas-dev/pandas/issues/18530 Hopefully we can quickly fix this

2reactions
jorisvandenbosschecommented, Nov 14, 2017

As I said above and please read the comments above, if it is the same problem you need to install them separately, so pip install numpy=1.12.0 and then pip install pandas=0.21.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix Python Numpy/Pandas installation? - Stack Overflow
So Numpy 1.6 doesn't seems to be installed correctly ! I tried to install Numpy 1.6 with pip (instead of easy_install )... $...
Read more >
How to Fix ImportError: No module named pandas [Mac/Linux ...
To fix it, run pip install pandas in your Linux/MacOS/Windows terminal. ... The code will run after your installation completes successfully.
Read more >
Installation β€” pandas 1.5.2 documentation
Installing from PyPI​​ pandas can be installed via pip from PyPI. You must have pip>=19.3 to install from PyPI.
Read more >
pip install pandas error mac - Coffeenote
2: Successfully uninstalled pandas-1. cpl, and press Enter. Step 4: Enter the following command to install Pandas using pip3. 1) on Mac OS...
Read more >
2 Easy Methods For Installing Pandas on Your Windows ...
Screenshot of command line terminal after installing pandas with the Python pip software. The above command shows that the process successfully ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found