Skip to content

pyparsing version parsing error - #2266

Merged
dmcdougall merged 1 commit into
matplotlib:v1.3.xfrom
mdboom:fix-pyparsing-cruft
Aug 18, 2013
Merged

dmcdougall merged 1 commit into
matplotlib:v1.3.xfrom
mdboom:fix-pyparsing-cruft

Conversation

@mdboom

@mdboom mdboom commented Aug 7, 2013

Copy link
Copy Markdown
Member

With the 1.3.0 build from Gohlke's site (http://www.lfd.uci.edu/~gohlke/pythonlibs/), when I try to import matplotlib, I get a pyparsing error. I have pyparsing 2.0.1 installed. Here's the error:

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 121, in <mod
ule>
    '.'.join(str(x) for x in _required)))
ImportError: matplotlib requires pyparsing >= 1.5.6

@ibell

ibell commented Aug 1, 2013

Copy link
Copy Markdown
Author

Perhaps it would be nice if the error message gave what it thought the version installed was

@mdboom

mdboom commented Aug 1, 2013

Copy link
Copy Markdown
Member

We can improve the error message. In the meantime, can you tell me what

>>> import pyparsing
>>> pyparsing.__version__

gives on your system?

@ibell

ibell commented Aug 1, 2013

Copy link
Copy Markdown
Author
>>> import pyparsing
>>> pyparsing.__version__
'2.0.1'
>>>

@WeatherGod

Copy link
Copy Markdown
Member

Mike, this is the same error I was having because I didn't do a git clean
-fxd. The cause of it was that the old pyparsing.pyc file was still in the
build directory and got picked up during install.

Chances are, the binaries weren't builtt from clean tarballs.

On Thu, Aug 1, 2013 at 9:04 AM, Michael Droettboom <notifications@github.com

wrote:

We can improve the error message. In the meantime, can you tell me what

import pyparsing
pyparsing.version

gives on your system?

—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2266#issuecomment-21934696
.

@mdboom

mdboom commented Aug 1, 2013

Copy link
Copy Markdown
Member

@ibell: To confirm @WeatherGod's theory, can you look in C:\Python27\lib\site-packages\matplotlib and see if there is a pyparsing.pyc file there?

@ibell

ibell commented Aug 1, 2013

Copy link
Copy Markdown
Author

Yes, but it is a compiled version of the "correct" pyparsing module as far
as I can tell. I deleted the .pyc file and when I import pyparsing again I
still get the same version.

On Thu, Aug 1, 2013 at 4:02 PM, Michael Droettboom <notifications@github.com

wrote:

@ibell https://github.com/ibell: To confirm @WeatherGodhttps://github.com/WeatherGod's
theory, can you look in C:\Python27\lib\site-packages\matplotlib and see
if there is a pyparsing.pyc file there?

—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2266#issuecomment-21938132
.

@mdboom

mdboom commented Aug 1, 2013

Copy link
Copy Markdown
Member

Just to be clear, you're looking in C:\Python27\lib\site-packages\matplotlib and not C:\Python27\lib\site-packages, right? Does removing the one in C:\Python27\lib\site-packages\matplotlib resolve the error?

@WeatherGod

Copy link
Copy Markdown
Member

No, that's not what I meant. The new installer would have put the bad
pyparsing file in the egg that got installed. That directory is from the
previous version of matplotlib and is never touched when importing
matplotlib after the 1.3 install.

Ben

On Thu, Aug 1, 2013 at 10:02 AM, Michael Droettboom <
notifications@github.com> wrote:

@ibell https://github.com/ibell: To confirm @WeatherGodhttps://github.com/WeatherGod's
theory, can you look in C:\Python27\lib\site-packages\matplotlib and see
if there is a pyparsing.pyc file there?

—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2266#issuecomment-21938132
.

@mdboom

mdboom commented Aug 1, 2013

Copy link
Copy Markdown
Member

@WeatherGod: I'm confused. Which directory is from the previous installation of matplotlib? As far as I can tell, the installer installs to C:\Python27\lib\site-packages\matplotlib whether it's matplotlib 1.2.1 or 1.3.0. Whether the pyparsing.py (inside of the matplotlib directory) came from 1.2.1 or erroneously in the 1.3.0 installer, it would be there either way, and removing it should resolve the issue you describe. (The only difference is how we ultimately resolve it from our end). Am I missing something?

@mdboom

mdboom commented Aug 1, 2013

Copy link
Copy Markdown
Member

I just confirmed that pyparsing is not in the installer, so I suspect it was left over from a previous install.

One possible solution to this (besides recommending uninstallation first), is to put from __future__ import absolute_import at the top of matplotlib/__init__.py so that the pyparsing imported will always be the global one and not the one that used to be included with matplotlib.

@ibell

ibell commented Aug 2, 2013

Copy link
Copy Markdown
Author

I hadn't even realized that MPL provided a version of pyparsing. At the
very least the error message should be clear about which pyparsing it is
talking about. I think it would be better to just use the system version,
or try the system pyparsing, and if it isn't up to date, use the MPL one.

On Thu, Aug 1, 2013 at 4:32 PM, Michael Droettboom <notifications@github.com

wrote:

I just confirmed that pyparsing is not in the installer, so I suspect it
was left over from a previous install.

One possible solution to this (besides recommending uninstallation first),
is to put from future import absolute_import at the top of
matplotlib/init.py so that the pyparsing imported will always be the
global one and not the one that used to be included with matplotlib.

—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2266#issuecomment-21940274
.

@transientlunatic

Copy link
Copy Markdown

I've had this problem today as well after installing matplotlib through pip, and as far as I can tell is related to #1792 and #1794. The output from pip is

Downloading/unpacking pyparsing>=1.5.6,!=2.0.0 (from matplotlib)
  Running setup.py egg_info for package pyparsing

I notice pyparsing has recently released (two weeks ago, according to PyPI) a version 2.0.1, so, as far as I can tell, what pip is now doing is installing that rather than installing from the 1.x branch, since 2.0.1 is both greater than 1.5.6 and not equal to 2.0.0.

@jenshnielsen

Copy link
Copy Markdown
Member

Which is the intention since 2.0.1 works for python 2.6 and 2.7 again see #2240

@jenshnielsen

Copy link
Copy Markdown
Member

I have tested mpl 1.3.0 and python 2.7.5 with this version and apart from a lot of depresiation warnings it is all
fine. The alternative would be that pip tried to downgrade a working 2.0.1 install to 1.5.6 if you had 2.0.1 installed.

@mdboom

mdboom commented Aug 2, 2013

Copy link
Copy Markdown
Member

I hadn't even realized that MPL provided a version of pyparsing. At the
very least the error message should be clear about which pyparsing it is
talking about. I think it would be better to just use the system version,
or try the system pyparsing, and if it isn't up to date, use the MPL one.

matplotlib used to include pyparsing, and if I understand correctly, this failure is due to having a previous version of matplotlib installed first, and then installing 1.3.0 on top. In that situation, it is loading the too old pyparsing that matplotlib shipped with. @ibell: Can you confirm that's the case on your system so I know my theory is correct? Did removing C:\Python27\lib\site-packages\matplotlib resolve the issue for you? If that's the case, I think the fix will be to use absolute imports so we can be clear that we want the system pyparsing. matplotlib no longer ships pyparsing (for a number of good reasons) so falling back to its version is no longer an option.

@mdboom

mdboom commented Aug 7, 2013

Copy link
Copy Markdown
Member

@ibell: ping. I'm not comfortable making any changes unless we can confirm the root cause of the problem.

@ibell

ibell commented Aug 7, 2013

Copy link
Copy Markdown
Author

Sorry for the delay - removing the matplotlib folder entirely makes the
1.3.0 installer work with a system-installed 2.0.1

On Wed, Aug 7, 2013 at 11:39 PM, Michael Droettboom <
notifications@github.com> wrote:

@ibell https://github.com/ibell: ping. I'm not comfortable making any
changes unless we can confirm the root cause of the problem.

—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2266#issuecomment-22286409
.

@ibell

ibell commented Aug 7, 2013

Copy link
Copy Markdown
Author

Thats the matplotlib folder in site-packages

On Wed, Aug 7, 2013 at 11:45 PM, Ian Bell ian.h.bell@gmail.com wrote:

Sorry for the delay - removing the matplotlib folder entirely makes the
1.3.0 installer work with a system-installed 2.0.1

On Wed, Aug 7, 2013 at 11:39 PM, Michael Droettboom <
notifications@github.com> wrote:

@ibell https://github.com/ibell: ping. I'm not comfortable making any
changes unless we can confirm the root cause of the problem.

—
Reply to this email directly or view it on GitHubhttps://github.com//issues/2266#issuecomment-22286409
.

… from matplotlib 1.1.1 (or earlier) if it's still around in the user's site-packages.
@mdboom

mdboom commented Aug 8, 2013

Copy link
Copy Markdown
Member

Ok -- I've done a little more digging around. To summarize: the bug manifests itself when the user installs 1.1.1 (or earlier), and then installs 1.3.0 over top (possibly with 1.2.x in between). This is because 1.1.1 (and earlier) include a file called pyparsing.py in the matplotlib package. 1.2.0 include the files pyparsing_py2.py and pyparsing_py3.py in the matplotlib namespace. 1.3.0 includes none of the above, but does import pyparsing expecting the system one, and, in the case of old matplotlib cruft left lying around, get the by-now-too-old version of pyparsing that shipped with 1.1.1.

The obvious fix is to turn on absolute_import so that the system pyparsing will be preferred over the local one. The attached patch fixes things for me in my testing.

We'll have to advertise, for now, that installing 1.3.0 requires uninstalling earlier versions first. But once this fix gets in (for 1.3.1, which looks inevitable rather soon for a number of reasons), that will no longer be required.

dmcdougall added a commit that referenced this pull request Aug 18, 2013
@dmcdougall
dmcdougall merged commit 25a2626 into matplotlib:v1.3.x Aug 18, 2013
@killmen2006

Copy link
Copy Markdown

hi I have got exactly the same problem and the solution is:
1 download pyparsing 1.5.6(download the zip source code not exe)
2 unzip
3 copy the pyparsing.py pyparsing.pyc and pyarsing.pyo in to C:\Python27\lib\site-packages\matplotlib and overwrite the old pyparsing files
4 done!

@mdboom

mdboom commented Aug 28, 2013

Copy link
Copy Markdown
Member

@killmen2006: The better solution is to remove your old installation of matplotlib before reinstalling a new one, and installing pyparsing in the standard way. This will allow you to continue to upgrade matplotlib in the future without this hiccup.

@ptmcg

ptmcg commented Sep 23, 2013

Copy link
Copy Markdown

Sorry about all those deprecation warnings about using '<<' operator. It turns out '<<' won't be deprecated after all, so in version 2.0.2, those warnings will all go away.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants