Skip to content

ImportError with pandas 0.20.0 and 0.20.1 #16288

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
FragLegs opened this issue May 8, 2017 · 8 comments · Fixed by #16294
Closed

ImportError with pandas 0.20.0 and 0.20.1 #16288

FragLegs opened this issue May 8, 2017 · 8 comments · Fixed by #16294
Labels
Bug IO Data IO issues that don't fit into a more specific label
Milestone

Comments

@FragLegs
Copy link
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
Copy link
Contributor

@jorisvandenbossche did you see something like this earlier?

@jorisvandenbossche
Copy link
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
Copy link
Member

@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 Bug IO Data IO issues that don't fit into a more specific label labels May 9, 2017
@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
Copy link
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
Copy link
Contributor Author

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.

@anntzer
Copy link
Contributor

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
Copy link
Member

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

@FragLegs
Copy link
Contributor Author

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.

TomAugspurger pushed a commit to TomAugspurger/pandas that referenced this issue May 29, 2017
TomAugspurger pushed a commit that referenced this issue May 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants