python2_3 import error

1,219 views
Skip to first unread message

rurpy

unread,
Oct 6, 2012, 12:40:35 AM10/6/12
to pyqt...@googlegroups.com
I just tried to install pyqtgraph-dev-r201 for evaluation:
 Linux (fedora 15), PyQt-4.8, ran "python setup.py install".
Install seemed fine but when I "import pyqtgraph" I get
  ImportError: cannot import name python2_3

I read
  https://groups.google.com/forum/#!topic/pyqtgraph/nvyHyp0giQw
that says using PyQt-4.9 gets rid of error but since my PyQt is a
distribution package with no 4.9 available, it is very difficult for me
to upgrade (short of upgrading Fedora which I can't justify right
now just to try out a plotting package).

Is this something that is fixable so that PyQt-4.8 can be used?

BTW, I also found I had to install scipy to get rid of an ImportError
on scipy.ndimage.  Would be nice if the web page mentioned this
(or other) dependencies.

Luke Campagnola

unread,
Oct 6, 2012, 1:38:28 AM10/6/12
to pyqt...@googlegroups.com
On Sat, Oct 6, 2012 at 12:40 AM, rurpy <ru...@yahoo.com> wrote:
I just tried to install pyqtgraph-dev-r201 for evaluation:
 Linux (fedora 15), PyQt-4.8, ran "python setup.py install".
Install seemed fine but when I "import pyqtgraph" I get
  ImportError: cannot import name python2_3

I read
  https://groups.google.com/forum/#!topic/pyqtgraph/nvyHyp0giQw
that says using PyQt-4.9 gets rid of error but since my PyQt is a
distribution package with no 4.9 available, it is very difficult for me
to upgrade (short of upgrading Fedora which I can't justify right
now just to try out a plotting package).

Is this something that is fixable so that PyQt-4.8 can be used?

PyQt 4.8 should definitely work. I still haven't figured out the source of this mystery import error. Since you're the second person to report this, I think I'm going to set up a few VMs for testing and see if I can reproduce it..
 
BTW, I also found I had to install scipy to get rid of an ImportError
on scipy.ndimage.  Would be nice if the web page mentioned this
(or other) dependencies.

Thanks; I added a list of dependencies to the web page. I'll also see about fixing that import requirement--scipy is supposed to be optional. 

 Luke

Luke Campagnola

unread,
Oct 7, 2012, 2:06:31 PM10/7/12
to pyqt...@googlegroups.com
On Sat, Oct 6, 2012 at 1:38 AM, Luke Campagnola <luke.ca...@gmail.com> wrote:
On Sat, Oct 6, 2012 at 12:40 AM, rurpy <ru...@yahoo.com> wrote:
I just tried to install pyqtgraph-dev-r201 for evaluation:
 Linux (fedora 15), PyQt-4.8, ran "python setup.py install".
Install seemed fine but when I "import pyqtgraph" I get
  ImportError: cannot import name python2_3

PyQt 4.8 should definitely work. I still haven't figured out the source of this mystery import error. Since you're the second person to report this, I think I'm going to set up a few VMs for testing and see if I can reproduce it..
 

Ok, I have installed Fedora 15 on a VM with PyQt 4.8.6. I am still able to import pyqtgraph without problems there, so I'm stumped on what could be causing this bug. 

If you have some free time, I would be most grateful if you could try a couple things for me:
1) remove  /usr/lib/python-2.7/site-packages/pyqtgraph/python2_3.pyc
     then try importing pyqtgraph and tell me whether the error has changed (I presume you will still get some error)
2) rename python2_3.py  to  asdf.py
     then edit pyqtgraph/__init__.py and change the import statement at line 22 to "from . import asdf"

rurpy

unread,
Oct 8, 2012, 2:02:45 AM10/8/12
to pyqt...@googlegroups.com
First, I have to say that when I reported the problem on friday
it was at the end of a long frustrating day of installing and
trying to use a dozen different plotting libs, and my patience
for dealing with problems was pretty thin.  When I encountered
the ImportError, I looked in the forum, found it was a previously
reported problem, and reported it again without any further
investigation.

Today, when I tried pyqtplot again for the first time after
reporting the problem, it imported fine, the examples run, and
everything seems good.  So sorry to have sent you on a wild
goose chase -- I should have tried import pyqtgraph more than
once before posting here.  But I guess at least I confirmed the
problem is not easily repeatable. :-)

Today I deleted pyqtgraph from .../site-packages/ and reinstalled
from the tar download as before.  I also deleted my user ~/.python27/
directory.  But I am still not able to reproduce the problem.  It only
happened that first time I tried importing after the initial install.

If you have some free time, I would be most grateful if you could try a couple things for me:
1) remove  /usr/lib/python-2.7/site-packages/pyqtgraph/python2_3.pyc
     then try importing pyqtgraph and tell me whether the error has changed (I presume you will still get some error)

I deleted the .../site-packages/pyqtgraph/python2_3.pyc
file but when I run python and import pyqtgraph, it (continues to)
import fine.

2) rename python2_3.py  to  asdf.py
     then edit pyqtgraph/__init__.py and change the import statement at line 22 to "from . import asdf"

Did that, and got:
   [...]
     from .GraphicsScene import *
  File "/usr/lib/python2.7/site-packages/pyqtgraph/GraphicsScene/GraphicsScene.py", line 3, in <module>
    from pyqtgraph.python2_3 import sortList
  ImportError: No module named python2_3
(there seem to be many places besides __init__.py where it is imported.)

I want to add that pyqtgraph seems really excellent.  Although it was
at the bottom of my list for evaluation (because I'd not heard of it
before) it is now at the top.  Thanks for the past and ongoing
efforts in developing this!

Luke Campagnola

unread,
Oct 8, 2012, 9:46:44 AM10/8/12
to pyqt...@googlegroups.com
On Mon, Oct 8, 2012 at 2:02 AM, rurpy <ru...@yahoo.com> wrote:
Today, when I tried pyqtplot again for the first time after
reporting the problem, it imported fine, the examples run, and
everything seems good. 

The mystery bug lives on :)
Thanks for your help.

Luke

 

Declan O Hara

unread,
Mar 16, 2013, 10:43:23 PM3/16/13
to pyqt...@googlegroups.com
Hi, I have also had the same problem. After following the advice you gave above, I am now left with:

  File "C:\Users\Ciaran\Downloads\eclipse-SDK-4.2.2-win32-x86_64\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydev_runfiles.py", line 432, in __get_module_from_str
    mod = __import__(modname)
  File "C:\Users\Ciaran\workspace\FYP\CSV_direct.py", line 8, in <module>
    import pyqtgraph as pg
  File "C:\Python27\lib\site-packages\pyqtgraph\__init__.py", line 22, in <module>
    from . import asdf
ImportError: cannot import name asdf

Please give advice if you have any ideas, thanks.
Declan

Luke Campagnola

unread,
Mar 17, 2013, 8:24:35 AM3/17/13
to pyqt...@googlegroups.com
On Sat, Mar 16, 2013 at 10:43 PM, Declan O Hara <declano...@gmail.com> wrote:
Hi, I have also had the same problem. After following the advice you gave above, I am now left with:

  File "C:\Users\Ciaran\Downloads\eclipse-SDK-4.2.2-win32-x86_64\eclipse\plugins\org.python.pydev_2.7.1.2012100913\pysrc\pydev_runfiles.py", line 432, in __get_module_from_str
    mod = __import__(modname)
  File "C:\Users\Ciaran\workspace\FYP\CSV_direct.py", line 8, in <module>
    import pyqtgraph as pg
  File "C:\Python27\lib\site-packages\pyqtgraph\__init__.py", line 22, in <module>
    from . import asdf
ImportError: cannot import name asdf

Please give advice if you have any ideas, thanks.
Declan


Hi Declan, 
I have found that when I see a failure to import python2_3, it is always preceded by a more interesting error message. I would take out the "import asdf" line you added and send me the _first_ exception you see after trying to import pyqtgraph (there will probably be a very long list of exceptions).

Luke

Binoy U

unread,
May 4, 2013, 12:04:11 PM5/4/13
to pyqt...@googlegroups.com

Hi

I changed the name to asdf, the i got the following error

import pyqtgraph

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    import pyqtgraph
  File "C:\Python27\lib\site-packages\pyqtgraph\__init__.py", line 33, in <module>
    from . import numpy_fix
ImportError: cannot import name numpy_fix

So i deleted the numpy_fix.pyc and pyo file and tried importing again and getting the same error again :(
>>> import pyqtgraph

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    import pyqtgraph
  File "C:\Python27\lib\site-packages\pyqtgraph\__init__.py", line 30, in <module>

Luke Campagnola

unread,
May 4, 2013, 1:28:24 PM5/4/13
to pyqt...@googlegroups.com
On Sat, May 4, 2013 at 12:04 PM, Binoy U <binoy...@gmail.com> wrote:
I changed the name to asdf, the i got the following error

import pyqtgraph

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    import pyqtgraph
  File "C:\Python27\lib\site-packages\pyqtgraph\__init__.py", line 33, in <module>
    from . import numpy_fix
ImportError: cannot import name numpy_fix

So i deleted the numpy_fix.pyc and pyo file and tried importing again and getting the same error again :(
>>> import pyqtgraph

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    import pyqtgraph
  File "C:\Python27\lib\site-packages\pyqtgraph\__init__.py", line 30, in <module>
    from . import asdf
ImportError: cannot import name asdf


Hello,
The asdf suggestion I gave above was not meant to fix the problem, but rather to help me diagnose the problem since I was not able to reproduce it.
Can you tell me: 1) what environment are you using to run python (I noticed "pyshell" in the stack trace, which may be part of your problem.  2) with a clean, unmodified pyqtgrapg, what is the first error message you get after trying to import?


Luke








 

Binoy U

unread,
May 6, 2013, 12:04:34 AM5/6/13
to pyqt...@googlegroups.com
Hi Luke,

Thank you for replying. I just started using pyqtgrpah and PyQt4. I tried in pyshell.  Initially i was getting long list of exception which ends with Numpy import error, so installed numpy module.
Again i got import error or  scipy.fft. So installed SciPy module. Then i got the Error i mentioned in the previous message.
I'm using a win8 64 bit machine. Python 2.7.4 installed.

Luke Campagnola

unread,
May 6, 2013, 9:02:30 AM5/6/13
to pyqt...@googlegroups.com
On Mon, May 6, 2013 at 12:04 AM, Binoy U <binoy...@gmail.com> wrote:
Hi Luke,

Thank you for replying. I just started using pyqtgrpah and PyQt4. I tried in pyshell.  Initially i was getting long list of exception which ends with Numpy import error, so installed numpy module.
Again i got import error or  scipy.fft. So installed SciPy module. Then i got the Error i mentioned in the previous message.
I'm using a win8 64 bit machine. Python 2.7.4 installed.


Ok, the error mentions that it cannot import 'numpy_fix'. 
 - Can you verify that you have the file pyqtgraph/numpy_fix.py installed? 
 - No other errors appear before the 'numpy_fix' error?
 - Do you still have the problem when running without pyshell? (for example, just use "python -i" from the command prompt)


Luke

Binoy U

unread,
Dec 13, 2013, 3:19:36 AM12/13/13
to pyqt...@googlegroups.com
Hi Luke,

When Im running this on IDLE only im getting the issue. Issue is not found on Python shell. No issue for running the script from a file.

Thanks you for the help. Also sorry for the delay

Luke Campagnola

unread,
Dec 13, 2013, 12:24:57 PM12/13/13
to pyqt...@googlegroups.com
On Fri, Dec 13, 2013 at 3:19 AM, Binoy U <binoy...@gmail.com> wrote:
Hi Luke,

When Im running this on IDLE only im getting the issue. Issue is not found on Python shell. No issue for running the script from a file.

Thanks you for the help. Also sorry for the delay


I am still not able to reproduce this in Idle on either windows or Linux. I recommend making a clean installation from the latest version and see if the problem persists.

 

John Freudenthal

unread,
Dec 19, 2013, 6:33:05 PM12/19/13
to pyqt...@googlegroups.com
I have been fighting with this problem all day. I know this isn't a terribly helpful solution, but I did manage to solve the 


 ImportError: cannot import name python2_3

using drastic measures. I have installed both PySide and PyQt4.9 . I figured this was likely the problem, so I removed PyQT4.9. No good. I then installed only Python, PySide, pyqtgraph and all dependencies on another machine. Worked fine. So I deleted everything; python27, pyside, pyqt4.9, pyqtgraph everything python related. Then reinstalled everything. Works great.

Drastic, needless and doesn't really solve the root of the issue, but I have graphs now.

Thanks.

Ken King

unread,
Dec 17, 2015, 4:14:17 AM12/17/15
to pyqtgraph
Same problem meet. But I solve it at last with small trick:
just rename the "python2_3.pyc" & "python2_3.pyo" to "python2_3xxxxx.pyc" & "python2_3xxxxx.pyo", then problem solved. 
Or delete these two file also should OK.

在 2013年12月20日星期五 UTC+8上午7:33:05,John Freudenthal写道:

herr goertz

unread,
Jan 11, 2016, 5:09:13 AM1/11/16
to pyqtgraph
Ken Kings solution worked for me.
Reply all
Reply to author
Forward
0 new messages