Saving figures with matplotlib on NFS filesystem - python

I am using ipython notebook through Anaconda on RHEL 6.7. The machine is set up with an NFS storage; that is, df -P -T /home/USERNAME | tail -n +2 | awk '{print $2}' prints 'nfs'.
So I want to save matplotlib figures created in ipython notebooks. Calling the savefig function, however, gives me this error (I have suppressed most of it):
RuntimeError: dvipng was not able to process the following file:
/home/USERNAME/.cache/matplotlib/tex.cache/3007d273a0b2642aa3abce6d3d640283.dvi
Here is the full report generated by dvipng:
No dvipng error report available.
My suspicion is that this has to do with NFS (since it has given me other problems in the past) but otherwise I don't really know where to go from here. Any help greatly appreciated, and please let me know if I can provide more information.

The same problem occurs here in an up-to-date OpenSuse Leap VM with an also up-to-date stack of Anaconda. To my dismay it is not deterministic: batch generating plots fails at very different datasets. It helped to insert a
time.sleep(5)
and now the problem occurs much less frequently. Still a PITA though.

This may not strictly be a problem of NFS.
Looking at its source in this line and this line (note that here is an error: It should have said "dvips failed", not "dvipng"), it seems that the external command with dvipng or dvips failed.
So there are many possibilities. First you need to figure out which external program was being system()ed. Then, maybe you need to check whether this command could be found in PATH environment variable at all, or whether the file itself is crashing that command. Try running dvip(ng|s) manually on that file and see if you can get an error report.
BTW, from the linked source, if I read the source correctly (IIRTSC), I don't think the matplotlib library is doing the right thing to catch an error report by capturing the stdout of dvip(ng|s) command. And we know os.system() is evil ...

Without properly maintained LateX packages, matplotlib (at least running through a Jupyter notebook) apparently is unable to save LateX-formatted plots, even if they display correctly.

Related

Process finished with exit code -805306369 (0xCFFFFFFF) [duplicate]

I'm running a python script and it used to work (it even does on my other laptop right now) but not on my current computer - I just get the error code:
Process finished with exit code -1073741515 (0xC0000135)
I don't get any other results - not even from "print" commands at the beginning of the file.
I haven't found anything specific to that.
I re-installed python (2.7.9), pygame (1.9.1) and even pycharm (tried 4.5 first, now with 5.0 - same result)
Does anyone know what that error code means? I couldn't find anything about it.
reinstall python – you don't have python33.dll in c:\WINDOWS\system32\
Maybe you have different python versions – look at folders in root of c:
If yes, then point to your version of python.exe in pyCharm > Settings > Project Interpreter
This may be due to another program locking that memory location.
Before you try more drastic measures, know that restarting the computer fixed the problem for me.
The error seems to be related to issues in native code (e.g. C/C++) and might be related to issues in loading some dll file. To know which file, the Windows "Event Viewer" is your friend.
The "Event Viewer" -> "Windows Logs" -> "Application" feed usually shows one or more rows for each crashed application and one of them should list the problematic filename.
Personally I observed similar issue with matplotlib on Python 3.9 (installed using Anaconda on Windows 10). I could see this kind of error when the code was executed using PyCharm. The same code just crashed with no visible errors when starting from Anaconda console.
The Event viewer then showed issue with freetype.dll. In this case, the problem was fixed by downgrading the packege from 2.11.0 to 2.10.4:
conda install freetype=2.10.4
Depending on the exact issue, I could imagine that removing pycache folder might help (like mentioned in other answers). Also, sometimes it might make sense to look at the PATH environment variable to actually understand why certain dll file is loaded from such a location.
I got this error in PyCharm after upgrading pyarrow to the most recent version -- 0.16 --- using pip, running the same code I had ran before this update which used pandas read_parquet specifying the engine="pyarrow" triggering use of this library. After uninstalling and installing the previous version with
pip install pyarrow=="0.15"
the problem resolved.
I encountered the same error when running .py in PyCharm on Windows. Inspired by https://thenewboston.com/forum/topic.php?id=10088, I uninstalled and reinstalled Python. When reinstalling, I checked the ADD PYTHON TO THE PATH Option. After recreating the virtual environment in PyCharm, the error was gone.
Update: On another Windows PC (64-bit), I encountered the same error where reinstalling Python was not enough. I tried two things.
Uninstalling 32-bit Python and installing 64-bit Python. Namely downloading python-3.6.4-amd64.exe instead of python-3.6.4.exe
Recreating the Pycharm project from github.
Between the two actions, the error was gone.
taskkill /F /IM python.exe
Try this if it just happened out of the bloom and it worked normally before that error occurred.
I solved it by disabling "PyQt compatible" checkbox in the Settings under Build, Execution, Deployment --> Python Debugger.
After that, it should debug properly.
Here is caused it and solution:
The computer had two physical processors. The code uses Numba for parallel computations. Upon disabling and re-enabling hyperthreading this issue started. To solve it clear pycache folder and run the program.
I encountered this error in my code as well, in my case the problem was sharing pickle which produced in Unix machine one a Windows one.
**I faced the same situation and the malfunction stems from trying to run both terminal processor and graphical user interfaces. When I clicked the button program stopped running **
Solution: I disabled terminal inputs and work with graphics.
For example:
if you do this
entry1=Entry(root,width=10).pack()
variable= str(input("Whats your name?"))
You will see the error.
if you delete either entry1 or variable, you will not see the problem.
If you're trying create a .svm use dlib probably the problem is in .xml, some image that you use is cause the problem. Try to create a new .xml putting out a image(any image) or remove that your .xml and test, try this even you find out the image problem.
For exemple, the image "treinamento3.jpg" was the problem. I removed this command line:
< image file='delirium\treinamento3.jpg'>
< box top='213' left='86' width='46' height='49'/ >
< box top='531' left='47' width='125' height='123'/ >
< /image >
from my .xml for solve my problem.

configuring theano in windows ? ' where to put the .theanorc.txt

I've followed this installation tutorial :
http://deeplearning.net/software/theano/install_windows.html#install-windows
As described in the tutorial, I've put the .theanorc.txt file in :
c:\scisoft\WinPython-64bit-2.7.9.4\settings
I was able to run the test program from the shell created by env.bat and to see the it uses the GPU.
Now I want to develop from pycharm not the "cmd", but there is get:
WARNING (theano.configdefaults): g++ not detected !
Theano will be unable to execute optimized C-implementations
(for both CPU and GPU) and will default to Python implementations.
Performance will be severely degraded.
To remove this warning, set Theano flags cxx to an empty string.
I assume because he can't find the .theanorc.txt
So I found this tutorial:
http://deeplearning.net/software/theano/library/config.html
He says to put the file in $HOME, but i don't have such environment variable.
I've tried to add it, but it didn't helped.
Any ideas ? I red tens of questions regarding it in stack overflow, but couldn't find an answer to this
I did this myself just recently... nearly the exact situation!
If you running an external IDE (i.e., not WinPython/Spyder), you need to put .theanorc in your Windows Users folder.
For example: C:\Users[Your Name]\
Note, I also recommend using the filename .theanorc not .theanorc.txt. I read that either works, but I seem to recall only one of them working for me.

Using ptrepack to reclaim deleted nodes in hdf5 file

I have written a bunch of pandas DataFrames to a h5 file using the Pytables integration in pandas. Since then I've deleted some of the groups in the h5 file and I want to repack it in order to reclaim the space. From what I've found I know I need to use the Pytables ptrepack tool. However I can't get it to work. Can someone let me know if I'm messing something up in my script or if I'm actually running across a bug in pytables? If I am messing it up can you give me an example for importing, and calling ptrepack to simply repack a h5 file in order to save space?
Here's my script and the errors I get:
When I looked at the ptrepack.py script in the pytables folder in anaconda I also saw that I should be able to pass a help flag to it.. but that's also not working. Here's the error I get when I try get the help flag to work
Currently I'm working on a windows 10 machine
with the following package versions:
python 3.5.1
pytables: 3.2.2
pandas: 0.18.0
Thanks!
Ok, firstly, to get the help dialog to show in the command prompt you have to do either ptrepack -h or ptrepack --help
I didn't manage to get the script working in python as it seems it has been made specially for the command line- I did however find this very helpful notebook on the subject ([Reclaiming HDF5 Space][1]) which have the following solution
from subprocess import call
outfilename = 'out.h5'
command = ["ptrepack", "-o", "--chunkshape=auto", "--propindexes", filename, outfilename]
call(command)
Note that this essentially just starts a subprocess which calls the repack function.
[1]: https://github.com/jackdotwa/python-concepts/blob/master/hdf5/reclaiming_space.ipynb "Reclaiming HDF5 space"

More specific explanation to solve the issues with matplotlib in Python (macos)

I know that the answer was very promising answered in
here. But I seem to fail to follow the instructions, at least I still get an error in my notebook.
In my terminal, I first use
cd ~/.matplotlib
Then it says I need to create a new file named matplotlibrc, so I run
touch matplotlibrc.
To add the code backend: TkAgg I run
echo "backend: TkAgg"
After doing that, I still get the very same error message.
First Question: Is my code correct? If yes, my second question is if anybody knows a different solution to the problem.

Process finished with exit code -1073741515 (0xC0000135)

I'm running a python script and it used to work (it even does on my other laptop right now) but not on my current computer - I just get the error code:
Process finished with exit code -1073741515 (0xC0000135)
I don't get any other results - not even from "print" commands at the beginning of the file.
I haven't found anything specific to that.
I re-installed python (2.7.9), pygame (1.9.1) and even pycharm (tried 4.5 first, now with 5.0 - same result)
Does anyone know what that error code means? I couldn't find anything about it.
reinstall python – you don't have python33.dll in c:\WINDOWS\system32\
Maybe you have different python versions – look at folders in root of c:
If yes, then point to your version of python.exe in pyCharm > Settings > Project Interpreter
This may be due to another program locking that memory location.
Before you try more drastic measures, know that restarting the computer fixed the problem for me.
The error seems to be related to issues in native code (e.g. C/C++) and might be related to issues in loading some dll file. To know which file, the Windows "Event Viewer" is your friend.
The "Event Viewer" -> "Windows Logs" -> "Application" feed usually shows one or more rows for each crashed application and one of them should list the problematic filename.
Personally I observed similar issue with matplotlib on Python 3.9 (installed using Anaconda on Windows 10). I could see this kind of error when the code was executed using PyCharm. The same code just crashed with no visible errors when starting from Anaconda console.
The Event viewer then showed issue with freetype.dll. In this case, the problem was fixed by downgrading the packege from 2.11.0 to 2.10.4:
conda install freetype=2.10.4
Depending on the exact issue, I could imagine that removing pycache folder might help (like mentioned in other answers). Also, sometimes it might make sense to look at the PATH environment variable to actually understand why certain dll file is loaded from such a location.
I got this error in PyCharm after upgrading pyarrow to the most recent version -- 0.16 --- using pip, running the same code I had ran before this update which used pandas read_parquet specifying the engine="pyarrow" triggering use of this library. After uninstalling and installing the previous version with
pip install pyarrow=="0.15"
the problem resolved.
I encountered the same error when running .py in PyCharm on Windows. Inspired by https://thenewboston.com/forum/topic.php?id=10088, I uninstalled and reinstalled Python. When reinstalling, I checked the ADD PYTHON TO THE PATH Option. After recreating the virtual environment in PyCharm, the error was gone.
Update: On another Windows PC (64-bit), I encountered the same error where reinstalling Python was not enough. I tried two things.
Uninstalling 32-bit Python and installing 64-bit Python. Namely downloading python-3.6.4-amd64.exe instead of python-3.6.4.exe
Recreating the Pycharm project from github.
Between the two actions, the error was gone.
taskkill /F /IM python.exe
Try this if it just happened out of the bloom and it worked normally before that error occurred.
I solved it by disabling "PyQt compatible" checkbox in the Settings under Build, Execution, Deployment --> Python Debugger.
After that, it should debug properly.
Here is caused it and solution:
The computer had two physical processors. The code uses Numba for parallel computations. Upon disabling and re-enabling hyperthreading this issue started. To solve it clear pycache folder and run the program.
I encountered this error in my code as well, in my case the problem was sharing pickle which produced in Unix machine one a Windows one.
**I faced the same situation and the malfunction stems from trying to run both terminal processor and graphical user interfaces. When I clicked the button program stopped running **
Solution: I disabled terminal inputs and work with graphics.
For example:
if you do this
entry1=Entry(root,width=10).pack()
variable= str(input("Whats your name?"))
You will see the error.
if you delete either entry1 or variable, you will not see the problem.
If you're trying create a .svm use dlib probably the problem is in .xml, some image that you use is cause the problem. Try to create a new .xml putting out a image(any image) or remove that your .xml and test, try this even you find out the image problem.
For exemple, the image "treinamento3.jpg" was the problem. I removed this command line:
< image file='delirium\treinamento3.jpg'>
< box top='213' left='86' width='46' height='49'/ >
< box top='531' left='47' width='125' height='123'/ >
< /image >
from my .xml for solve my problem.

Categories

Resources