Skip to content
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

The "2to3" seems doesn't work while buliding matplotlib1.3.1 with python3.x #2655

Closed
ghost opened this issue Dec 6, 2013 · 6 comments
Closed

Comments

@ghost
Copy link

ghost commented Dec 6, 2013

My OS is ubuntu 13.10.
When I install mpl I tried :

python3.3 setup.py build
sudo python3.3 setup.py install

These all works fine……But when I create a new script like this:

import matplotlib

It throw me some errors, and obviously this is because of the differences between py2.x and py3.x
I try to google it and found this:
#1401

In that issue @pelson sad that 2to3 will run for the user. But I don't think so!

After install, I open the /usr/local/lib/python3.3/dist-packages/matplotlib-1.3.1-py3.3-linux-x86_64.egg/matplotlib/colors.py
and in this file I found:

# add british equivs
for k, v in cnames.items():
    if k.find('gray') >= 0:
        k = k.replace('gray', 'grey')
        cnames[k] = v

So you see the 2to3 doesn't work at all.

Then I copy the file to another place, and try to change it myself to test:

2to3 colors.py

this command only shows information on SCREEN, and dosen't do anything to the file itself!

only add-woptions will the 2to3 really work.

2to3 -Wn colors.py

this works right. And in the colors.py the code above changed to this:

# add british equivs
for k, v in list(cnames.items()):
    if k.find('gray') >= 0:
        k = k.replace('gray', 'grey')
        cnames[k] = v

I try to find where the SETUP and MAKE file use 2to3 but failed. So can anyone tells me how to do it?

Sorry for my poor English and thanks in advance!

@mdboom
Copy link
Member

mdboom commented Dec 6, 2013

Interesting. This should be working.

Try deleting both the build directory inside of the source tree and /usr/local/lib/python3.3/dist-packages/matplotlib-1.3.1-py3.3-linux-x86_64.egg and trying again.

Failing that, can you send me the full output of python setup.py install -- maybe post it in a gist?

@ghost
Copy link
Author

ghost commented Dec 8, 2013

Well……Finally I try to use 2to3 to modify the *.py file in /usr/local/lib/python3.3/dist-packages/matplotlib-1.3.1-py3.3-linux-x86_64.egg by myself.

Like:

sudo 2to3 -Wn /usr/local/lib/python3.3/dist-packages/matplotlib-1.3.1-py3.3-linux-x86_64.egg

This works~ And after I did that, most program statement such as:

import matplotlib

does works without exceptions, and I can run some of the script in example folder, But there're also many script just can't work, such as all script in /example/animation/ (so many exceptions throwed out in animation.py)and some other script run with exceptions……

So I think matplotlib is just not suit for python3, because developers create it with py2, and we shouldn't wish the computer will transfor it perfectly ……I try to install it with python2, and all of them works fine~
Thank you very much~~

@jenshnielsen
Copy link
Member

Matplotlib 1.3.1 definitely works fine in python 3.3. So there must be something wrong with either the way you install it or the python installation on your computer. Without some more verbose output it is very hard to figure out what is wrong so please provide the output of running the installation. 2to3 should run as part of the build script, it is not a big surprise that running it after the installation does not work as expected.

@ghost
Copy link
Author

ghost commented Dec 9, 2013

I reinstall it using the command:

python3.3 setup.py build
sudo python3.3 setup.py install --prefix=/usr/local >> matplotlib-install.txt

And code

import matplotlib

still get the same error:

File "/usr/local/lib/python3.3/dist-packages/matplotlib-1.3.1-py3.3-linux-x86_64.egg/matplotlib/colors.py", line 204, in <module>
    for k, v in cnames.items():
RuntimeError: dictionary changed size during iteration

2to3 doesn't work……

My Ubuntu13.10 installs both python2.7 and python3.3 in default. I mean the '"python" command refers to python2.7 and the "python3.3" refers to python3.3. Maybe this is what cause the problem?

And here is the installation output.
http://sdrv.ms/1cvuUXw

Thank you for replying!

@jenshnielsen
Copy link
Member

No because that is perfectly standard and works for everybody else.

Can you please delete the build folder within your source dir and rerun:

python3.3 setup.py build

And paste the output of that into a gist here. The output of the installation is less relevant because that is not when 2to3 is supposed to be running.

@jenshnielsen
Copy link
Member

This is how it looks for me

https://gist.github.com/jenshnielsen/7870124

After the copying you will see some lines with fixing and skipping. These are 2to3 running on the code before compiling the CPP extensions.

@ghost
Copy link
Author

ghost commented Dec 10, 2013

Amazing! It works! I delete the build folder and rebuild it, the code in colors.py has been modified, like:

# add british equivs
for k, v in list(cnames.items()):
    if k.find('gray') >= 0:
        k = k.replace('gray', 'grey')
        cnames[k] = v

Strange thing is that when I delete all of the source dir and uncompress a new one from the matplotlib-1.3.1.tar.gz package and rebuild, it will get into the same trouble mentioned above, while I only delete the build folder then rebuild, it performs well !

Command:

python3.3 setup.py build >> matplotlib-build.txt
============================================================================
Edit setup.cfg to change the build options

BUILDING MATPLOTLIB
            matplotlib: yes [1.3.1]
                python: yes [3.3.2+ (default, Oct  9 2013, 14:50:09)  [GCC
                        4.8.1]]
              platform: yes [linux]

REQUIRED DEPENDENCIES AND EXTENSIONS
                 numpy: yes [version 1.8.0]
              dateutil: yes [dateutil was not found. It is required for date
                        axis support. pip/easy_install may attempt to
                        install it after matplotlib.]
               tornado: yes [tornado was not found. It is required for the
                        WebAgg backend. pip/easy_install may attempt to
                        install it after matplotlib.]
             pyparsing: yes [pyparsing was not found. It is required for
                        mathtext support. pip/easy_install may attempt to
                        install it after matplotlib.]
                 pycxx: yes [Official versions of PyCXX are not compatible
                        with Python 3.x.  Using local copy]
                libagg: yes [pkg-config information for 'libagg' could not
                        be found. Using local copy.]
              freetype: yes [version 16.1.10]
                   png: yes [version 1.2.49]

OPTIONAL SUBPACKAGES
           sample_data: yes [installing]
              toolkits: yes [installing]
                 tests: yes [nose 0.11.1 or later is required to run the
                        matplotlib test suite]

OPTIONAL BACKEND EXTENSIONS
                macosx: no  [Mac OS-X only]
                qt4agg: no  [PyQt4 not found]
               gtk3agg: no  [gtk3agg backend does not work on Python 3]
             gtk3cairo: yes [installing, version 3.6.8]
                gtkagg: no  [Requires pygtk]
                 tkagg: no  [TKAgg requires Tkinter.]
                 wxagg: no  [requires wxPython]
                   gtk: no  [Requires pygtk]
                   agg: yes [installing]
                 cairo: yes [installing, version 1.10.0]
             windowing: no  [Microsoft Windows only]

OPTIONAL LATEX DEPENDENCIES
                dvipng: no
           ghostscript: yes [version 9.10]
                 latex: no
               pdftops: yes [version 0.24.1]

running build
running build_py
creating build
creating build/lib.linux-x86_64-3.3
copying lib/pylab.py -> build/lib.linux-x86_64-3.3
creating build/lib.linux-x86_64-3.3/matplotlib
copying lib/matplotlib/tight_layout.py -> build/lib.linux-x86_64-3.3/matplotlib
copying lib/matplotlib/image.py -> build/lib.linux-x86_64-3.3/matplotlib
/baseline_images/pngsuite
……
……
……
copying lib/matplotlib/tests/baseline_images/pngsuite/basn4a16.png -> build/lib.linux-x86_64-3.3/matplotlib/tests/baseline_images/pngsuite
copying lib/matplotlib/tests/baseline_images/pngsuite/basn2c16.png -> build/lib.linux-x86_64-3.3/matplotlib/tests/baseline_images/pngsuite
creating build/lib.linux-x86_64-3.3/matplotlib/tests/baseline_images/test_ttconv
copying lib/matplotlib/tests/baseline_images/test_ttconv/truetype-conversion.pdf -> build/lib.linux-x86_64-3.3/matplotlib/tests/baseline_images/test_ttconv
Fixing build/lib.linux-x86_64-3.3/pylab.py build/lib.linux-x86_64-3.3/matplotlib/tight_layout.py build/lib.linux-x86_64-3.3/matplotlib/image.py build/lib.linux-x86_64-3.3/matplotlib/markers.py build/lib.linux-x86_64-3.3/matplotlib/legend_handler.py build/lib.linux-x86_64-3.3/matplotlib/collections.py build/lib.linux-x86_64-3.3/matplotlib/offsetbox.py build/lib.linux-x86_64-3.3/matplotlib/sankey.py build/lib.linux-x86_64-3.3/matplotlib/colorbar.py build/lib.linux-x86_64-3.3/matplotlib/streamplot.py build/lib.linux-x86_64-3.3/matplotlib/spines.py build/lib.linux-x86_64-3.3/matplotlib/mpl.py build/lib.linux-x86_64-3.3/matplotlib/ticker.py build/lib.linux-x86_64-3.3/matplotlib/_mathtext_data.py build/lib.linux-x86_64-3.3/matplotlib/_pylab_helpers.py build/lib.linux-x86_64-3.3/matplotlib/blocking_input.py build/lib.linux-x86_64-3.3/matplotlib/container.py build/lib.linux-x86_64-3.3/matplotlib/pylab.py build/lib.linux-x86_64-3.3/matplotlib/type1font.py build/lib.linux-x86_64-3.3/matplotlib/cm.py build/lib.linux-x86_64-3.3/matplotlib/fontconfig_pattern.py build/lib.linux-x86_64-3.3/matplotlib/units.py build/lib.linux-x86_64-3.3/matplotlib/scale.py build/lib.linux-x86_64-3.3/matplotlib/animation.py build/lib.linux-x86_64-3.3/matplotlib/text.py build/lib.linux-
……
……
……
x86_64-3.3/matplotlib/tests/test_collections.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_backend_svg.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_contour.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_spines.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_lines.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_sankey.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_table.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_mathtext.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_animation.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_simplification.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_artist.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_basic.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_backend_qt4.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_cbook.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_colors.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_scale.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_ttconv.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_subplots.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_compare_images.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_figure.py
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
Fixing build/lib.linux-x86_64-3.3/pylab.py build/lib.linux-x86_64-3.3/matplotlib/tight_layout.py build/lib.linux-x86_64-3.3/matplotlib/image.py build/lib.linux-x86_64-3.3/matplotlib/markers.py build/lib.linux-x86_64-3.3/matplotlib/legend_handler.py build/lib.linux-x86_64-3.3/matplotlib/collections.py build/lib.linux-x86_64-3.3/matplotlib/offsetbox.py build/lib.linux-x86_64-3.3/matplotlib/sankey.py build/lib.linux-x86_64-3.3/matplotlib/colorbar.py build/lib.linux-x86_64-3.3/matplotlib/streamplot.py build/lib.linux-x86_64-3.3/matplotlib/spines.py build/lib.linux-x86_64-3.3/matplotlib/mpl.py build/lib.linux-x86_64-3.3/matplotlib/ticker.py build/lib.linux-x86_64-3.3/matplotlib/_mathtext_data.py build/lib.linux-x86_64-3.3/matplotlib/_pylab_helpers.py build/lib.linux-x86_64-3.3/matplotlib/blocking_input.py build/lib.linux-x86_64-3.3/matplotlib/container.py build/lib.linux-x86_64-3.3/matplotlib/pylab.py build/lib.linux-x86_64-3.3/matplotlib/type1font.py build/lib.linux-x86_64-3.3/matplotlib/cm.py build/lib.linux-x86_64-3.3/matplotlib/fontconfig_pattern.py build/lib.linux-x86_64-3.3/matplotlib/units.py build/lib.linux-x86_64-3.3/matplotlib/scale.py build/lib.linux-x86_64-3.3/matplotlib/animation.py build/lib.linux-x86_64-3.3/matplotlib/text.py build/lib.linux-……
……
……/matplotlib/tests/test_scale.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_ttconv.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_subplots.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_compare_images.py build/lib.linux-x86_64-3.3/matplotlib/tests/test_figure.py
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
running build_ext
building 'matplotlib.ft2font' extension
creating build/temp.linux-x86_64-3.3
creating build/temp.linux-x86_64-3.3/src
creating build/temp.linux-x86_64-3.3/CXX
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -DPYCXX_PYTHON_2TO3=1 -I/usr/local/lib/python3.3/dist-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/usr/include/freetype2 -I/usr/include/python3.3m -c src/ft2font.cpp -o build/temp.linux-x86_64-3.3/src/ft2font.o
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -DPYCXX_PYTHON_2TO3=1 -I/usr/local/lib/python3.3/dist-packages/numpy/core/include -I/usr/local/include -I/usr/include -I. -I/usr/include/freetype2 -I/usr/include/python3.3m -c src/mplutils.cpp -o build/temp.linux-x86_64-3.3/src/mplutils.o
……
……
……
x86_64-3.3/agg24/src/agg_vpgen_segmentator.o build/temp.linux-x86_64-3.3/CXX/cxx_extensions.o build/temp.linux-x86_64-3.3/CXX/cxxsupport.o build/temp.linux-x86_64-3.3/CXX/IndirectPythonInterface.o build/temp.linux-x86_64-3.3/CXX/cxxextensions.o -L/usr/local/lib -lfreetype -lstdc++ -lm -o build/lib.linux-x86_64-3.3/matplotlib/backends/_backend_agg.cpython-33m.so

End of file

@ghost
Copy link
Author

ghost commented Dec 10, 2013

Anyway, most of the scripts in example folder can run normally, but still some of them just can't work.(like scripts in animation folder) The same result as I modify the script myself……It's a challenge to make the matplotlib suitable for python3.
Thank you very much !! :)

@tacaswell
Copy link
Member

Closing this because it was primarily a local install/configuration issue.

@untom
Copy link

untom commented Feb 22, 2014

Hi!
Sorry to open this up again, but I'm experiencing EXACTLY the same issues. On Ubuntu 13.10, I downloaded the matplotlib 1.3.1 and installed it via 'python3 setup.py install', and this is what happened:

$ python3
Python 3.3.2+ (default, Oct  9 2013, 14:50:09) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.3/dist-packages/matplotlib/__init__.py", line 183, in <module>
    from matplotlib.rcsetup import (defaultParams,
  File "/usr/local/lib/python3.3/dist-packages/matplotlib/rcsetup.py", line 21, in <module>
    from matplotlib.colors import is_color_like
  File "/usr/local/lib/python3.3/dist-packages/matplotlib/colors.py", line 204, in <module>
    for k, v in cnames.items():
RuntimeError: dictionary changed size during iteration
>>> 

However, after googling around and reading this thread, I went back into the matplotlib-1.3.1 folder, rm -rf build/ and redo python3 setup.py install.... After that, everything worked as expected.

$ python3
Python 3.3.2+ (default, Oct  9 2013, 14:50:09) 
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> 

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

No branches or pull requests

4 participants