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
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.

Contributor

TomAugspurger commented May 8, 2017

@jorisvandenbossche did you see something like this earlier?

Owner

jorisvandenbossche commented May 8, 2017 edited

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.

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

jreback added this to the 0.20.2 milestone May 9, 2017

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

@jreback jreback COMPAT: don't force clipboard routines to be imported in main pandas …
…started


closes #16288
627095a
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.

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 jreback added a commit to jreback/pandas that referenced this issue May 9, 2017

@jreback jreback COMPAT: don't force clipboard routines to be imported in main pandas …
…started


closes #16288
38a235a

jreback closed this in #16294 May 9, 2017

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.

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

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 pawroman added a commit to pawroman/pandas that referenced this issue May 9, 2017

@jreback @pawroman jreback + pawroman COMPAT: don't force clipboard routines to be imported in main pandas …
…started (#16294)


closes #16288
49fcab8

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

@jreback @pcluo jreback + pcluo COMPAT: don't force clipboard routines to be imported in main pandas …
…started (#16294)


closes #16288
38f66d1

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

@jreback @TomAugspurger jreback + TomAugspurger COMPAT: don't force clipboard routines to be imported in main pandas …
…started (#16294)


closes #16288
(cherry picked from commit 1e59b4c)
c7e3d61

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

@jreback @TomAugspurger jreback + TomAugspurger COMPAT: don't force clipboard routines to be imported in main pandas …
…started (#16294)


closes #16288
(cherry picked from commit 1e59b4c)
638f8b0

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

@jreback @stangirala jreback + stangirala COMPAT: don't force clipboard routines to be imported in main pandas …
…started (#16294)


closes #16288
54929c8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment