ImportError with pandas 0.20.0 and 0.20.1 #16288

Closed
FragLegs opened this Issue May 8, 2017 · 8 comments

Comments

Projects
None yet
5 participants
@FragLegs
Contributor

FragLegs commented May 8, 2017

Code Sample, a copy-pastable example if possible

With versions 0.20.0 and 0.20.1, I get the following error:

import pandas
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/smiel/.venvs/foo/local/lib/python2.7/site-packages/pandas/__init__.py", line 58, in <module>
    from pandas.io.api import *
  File "/home/smiel/.venvs/foo/local/lib/python2.7/site-packages/pandas/io/api.py", line 8, in <module>
    from pandas.io.clipboard.clipboard import read_clipboard
  File "/home/smiel/.venvs/foo/local/lib/python2.7/site-packages/pandas/io/clipboard/__init__.py", line 103, in <module>
    copy, paste = determine_clipboard()
  File "/home/smiel/.venvs/foo/local/lib/python2.7/site-packages/pandas/io/clipboard/__init__.py", line 76, in determine_clipboard
    return init_qt_clipboard()
  File "/home/smiel/.venvs/foo/local/lib/python2.7/site-packages/pandas/io/clipboard/clipboards.py", line 49, in init_qt_clipboard
    from PyQt4.QtGui import QApplication
ImportError: No module named sip

This does not occur with 0.19.2

Here are the other packages installed in my virtualenv

$ pip freeze
appdirs==1.4.3
numpy==1.12.1
packaging==16.8
pandas==0.20.1
pyparsing==2.2.0
python-dateutil==2.6.0
pytz==2017.2
PyYAML==3.12
six==1.10.0

Problem description

It would be nice if pandas was pip installable. As it stands, the new versions are not (for me).

Expected Output

No error when importing pandas.

Output of pd.show_versions()

I can't get that info without being able to import pandas.

@TomAugspurger

This comment has been minimized.

Show comment
Hide comment
@TomAugspurger

TomAugspurger May 8, 2017

Contributor

@jorisvandenbossche did you see something like this earlier?

Contributor

TomAugspurger commented May 8, 2017

@jorisvandenbossche did you see something like this earlier?

@jorisvandenbossche

This comment has been minimized.

Show comment
Hide comment
@jorisvandenbossche

jorisvandenbossche May 8, 2017

Member

Not exactly this error, but possibly related. For me the error with clipboard was something with from PyQt4 import QtCore.
For some reason, I had an empty PyQt4 package in site-packages next to PyQt5 (so import PyQt4 did work, which is used to check which clipboard backend to use, but then later on actual imports raise an error), and for some reason this started to give problems. Matplotlib also had this problem, so I am not sure it was pandas-related.

Member

jorisvandenbossche commented May 8, 2017

Not exactly this error, but possibly related. For me the error with clipboard was something with from PyQt4 import QtCore.
For some reason, I had an empty PyQt4 package in site-packages next to PyQt5 (so import PyQt4 did work, which is used to check which clipboard backend to use, but then later on actual imports raise an error), and for some reason this started to give problems. Matplotlib also had this problem, so I am not sure it was pandas-related.

@jorisvandenbossche

This comment has been minimized.

Show comment
Hide comment
@jorisvandenbossche

jorisvandenbossche May 8, 2017

Member

@FragLegs Is this in a clean (newly made) env? Or if not, can you see if you can reproduce it then as well?

Member

jorisvandenbossche commented May 8, 2017

@FragLegs Is this in a clean (newly made) env? Or if not, can you see if you can reproduce it then as well?

@jreback jreback added this to the 0.20.2 milestone May 9, 2017

jreback added a commit to jreback/pandas that referenced this issue May 9, 2017

@jreback

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback May 9, 2017

Contributor

yeah this tries to import the clipboard things at import time, not usage time. You can mitigate atm by installing xclip.

Contributor

jreback commented May 9, 2017

yeah this tries to import the clipboard things at import time, not usage time. You can mitigate atm by installing xclip.

@FragLegs

This comment has been minimized.

Show comment
Hide comment
@FragLegs

FragLegs May 9, 2017

Contributor

@jorisvandenbossche This was in a clean env (which starts with pip and wheel, I think, but that's it). I'll try preinstalling xclip and let you know if that helps.

Contributor

FragLegs commented May 9, 2017

@jorisvandenbossche This was in a clean env (which starts with pip and wheel, I think, but that's it). I'll try preinstalling xclip and let you know if that helps.

jreback added a commit to jreback/pandas that referenced this issue May 9, 2017

@jreback jreback closed this in #16294 May 9, 2017

jreback added a commit that referenced this issue May 9, 2017

@anntzer

This comment has been minimized.

Show comment
Hide comment
@anntzer

anntzer May 9, 2017

Note that always importing PyQt4.QtCore will also lead to a RuntimeError when PyQt5 is already imported. See e.g. https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/qt_compat.py#L37 where matplotlib first checks whether one of them has already been imported in which case it is used.

anntzer commented May 9, 2017

Note that always importing PyQt4.QtCore will also lead to a RuntimeError when PyQt5 is already imported. See e.g. https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/qt_compat.py#L37 where matplotlib first checks whether one of them has already been imported in which case it is used.

@jorisvandenbossche

This comment has been minimized.

Show comment
Hide comment
@jorisvandenbossche

jorisvandenbossche May 9, 2017

Member

@FragLegs Out of curiosity, can you check whether you have a PyQt4 directory in the site-packages of the env?

Member

jorisvandenbossche commented May 9, 2017

@FragLegs Out of curiosity, can you check whether you have a PyQt4 directory in the site-packages of the env?

@FragLegs

This comment has been minimized.

Show comment
Hide comment
@FragLegs

FragLegs May 9, 2017

Contributor

@jorisvandenbossche Shoot, I totally forgot that I had added a symlink to /usr/lib/python2.7/dist-packages/PyQt4 in my postmkvirtualenv script (as well as a symlink to /usr/lib/python2.7/dist-packages/sip.so). So yes, there is a PyQt4 directory in site-packages of the env I was testing in. Sorry about that bit of confusion.

fwiw - installing xclip does not solve the import problem for me.

@jreback Thanks for getting the fix merged so quickly! I can confirm that your commit works perfectly on my machine.

Contributor

FragLegs commented May 9, 2017

@jorisvandenbossche Shoot, I totally forgot that I had added a symlink to /usr/lib/python2.7/dist-packages/PyQt4 in my postmkvirtualenv script (as well as a symlink to /usr/lib/python2.7/dist-packages/sip.so). So yes, there is a PyQt4 directory in site-packages of the env I was testing in. Sorry about that bit of confusion.

fwiw - installing xclip does not solve the import problem for me.

@jreback Thanks for getting the fix merged so quickly! I can confirm that your commit works perfectly on my machine.

pawroman added a commit to pawroman/pandas that referenced this issue May 9, 2017

@TomAugspurger TomAugspurger referenced this issue in ContinuumIO/anaconda-issues May 10, 2017

Closed

Issues loading pandas after anaconda update #1713

pcluo added a commit to pcluo/pandas that referenced this issue May 22, 2017

TomAugspurger added a commit to TomAugspurger/pandas that referenced this issue May 29, 2017

TomAugspurger added a commit that referenced this issue May 30, 2017

stangirala added a commit to stangirala/pandas that referenced this issue Jun 11, 2017

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