-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Animation module errors out when using Python3 #1891
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
Comments
Hmm... I can't reproduce with matplotlib 1.2.1, python 3.3 and numpy 1.7 on a Fedora box. The traceback leads us into numpy, of course, so perhaps therein lies the bug. Can you open up a Python 3 interpreter and type:
|
I get the following:
I have numpy 1.7.0, mpl 1.2.1. |
Interesting. There's definitely something fishy going on. Maybe try to use the Python debugger to see what's going on here. This is not in matplotlib, but in code that is trying to import
|
How should I check for corrupted 'pycache' files? |
I'm not sure -- did you perhaps compile numpy and/or matplotlib with an earlier version of Python and then are now opening them with Python 3.3.1?
That line number 1609 doesn't make much sense with the version of
So perhaps you're somehow getting an older version of I think the only way to really figure this out (as there's a lot of redflags here that something is usual about your environment), is to start this up in the debugger:
and when it fails, start poking around and seeing where this non UTF-8 data is coming from that it's trying (and failing) to decode. If you haven't already done so, I'd try creating a new Python 3.3.1 environment and install everything (numpy, matplotlib etc) fresh into it after clearing the build directories. |
I am having the exact same issue while trying to run some older code after an update. Any new info on this? Also, @gns-ank are you by chance running Arch Linux? I have a nagging feeling that this is a packaging bug. Also, extra info: the error only happens when calling animation.save(); this might be a video codec problem. Using plt.show() or anything like that works without a snag. Any advice? |
I am also having the same issue, also on Arch Linux. By "same issue" I mean that if I run the same example code, I get the same error and traceback. I have tried recompiling matplotlib in its own directory to no avail. However, I have noticed that with my own code, I get a very different traceback (but the same error):
So... I don't know where this error is coming from, but it looks to me like the |
This problem frustrated me after I made the effort to setup a virtualenv for python3.3 on both my mac and linux boxes. I ended up abandoning that altogether in favor of the environment used to do these types of animations, It would still be nice to see the problem resolved for Python 3 however. |
It appears that the original bug is actually a bug in Numpy -- not it happens within importing |
@mdboom do you happen to know the corresponding bug in numpy or does that need to be filed? |
Re-reading this thread, it's possible it's not a bug in Numpy. @Juanlu001 -- can you provide the full traceback and exactly which version of matplotlib, Numpy, and Python you are running, on which platform, and how you set up the environment? |
Sure: The code is https://gist.github.com/Juanlu001/7674552 (swapping comments in lines 36 and 37 to run animation.save)
|
Well, I tried a lot and still can't figure out with the problem. I've tried to rebuild both numpy and matplotlib against current python (3.3.3) too. Here are something from pdb:
|
I just created a clean venv to test this, and I still get the same error. These were the steps I followed:
I think this bug is worth reopening. |
I've reproduced the same error on a clean Ubuntu 13.10 install (with python 3.3.2 / virtualenv). So it's not an Arch Linux only problem :p
|
import errors coming out of numpy. See issue matplotlib#1891.
The tests in The issue in 3.3 only and only seems to hit the streaming saves, not the aggregate a bunch of files saves. |
I'm experiencing this bug. Is there any workaround? How can I save video files in Python 3.3 environment? |
The simple (but very slow) work around is to use the file-based writers ( |
Same problem with Python 3.2.3, Numpy 1.6.1 and Matplotlib 1.3.0. The example in Matplotlib documentation: http://matplotlib.org/examples/animation/basic_example_writer.html for example, does not work. This is a quite bad bug. |
In |
Hi all, Here the traceback:
Any ideas?? |
Thanks @bytbox !!! It works I missed it! |
After applying @bytbox's patches to 1.3.x I am getting segaults. Python 3.4, numpy and matplotlib built from source. Any ideas? |
@tomasbedrich can you say what lines of code are triggering the segfaults? |
Unfortunately no, I'm on OS X 10.9 where valgrind doesn't work. |
What I mean is, what line of python causes a segfault? Can I have a minimal example? |
Here is minimal Python example:
I get the same result with
|
If this means that the problem is in line 160 of file_compat.h with #2898 applied, then it looks straightforward: it could be fixed by replacing the if (npy_lseek(fd, orig_pos, SEEK_SET) != -1) {
if (position == -1) {
PyErr_SetString(PyExc_IOError, "obtaining file position failed");
return -1;
}
/* Seek Python-side handle to the FILE* handle position */
ret = PyObject_CallMethod(file, "seek", MPL_OFF_T_PYFMT "i", position, 0);
if (ret == NULL) {
return -1;
}
Py_DECREF(ret);
}
return 0; In other words, move the |
(I'll fix and test this shortly. Thanks @efiring.) |
I can confirm that @efiring's quick patch is working. Thank you. |
I'm using python 3.4.0, with matplotlib 1.3.1 and am just trying to save my animation but get the errors described above. I see that this appears to be solved on your end but on my end I have no idea what to do to get this to function properly. Can anyone help me out? |
The simplest solution is to update to mpl 1.4.x. |
I used the double pendulum example and it did not work with the latest version of Matplotlib and Py3k on Arch Linux. However, it worked with Python2.7. I was using
as my shebang in the script.
The exact script which I used is here: https://gist.github.com/gns-ank/5347084#file-double_pendulum-py
The error log:
The text was updated successfully, but these errors were encountered: