Python Matplotlib show() on Debian - python

I am running Debian 8.7 (Jessie) on a development laptop. I am just getting into Python development for some machine learning projects I am working on. I also have Python installed on a my main Mac OSX macbook as well.
While working on some examples, the OSX install, when using plt.show() (from Matplotlib/pyplot), a window will pop up with the plot. On the Debian laptop, however, I get nothing back. No errors, nothing. I changed the plt.show() command to just save the figure out to a file and that works.
I read some forums and posts that talk about installing ImageMagick and other tools. I have tried that, but that didn't seem to work. Another option was to change the "backends". I also read something about using "eog" instead of the xv or display provided by the base OS. The post is located here:
matplotlib does not show my drawings although I call pyplot.show()
I went through this process, but that doesn't seem to work either. I'm wondering if this has something to with the fact that I had to download, configure and make the Python 3.6.1 version I am running on the Linux side. I'm still a little new at Python, so I'm unsure how to solve this.
Info:
OS: Debian 8.7 (Debian)
Python Version: 3.6.1
Packages Installed: pandas, matplotlib, bokeh, scikit-learn (and all the other major data science and machine learning libraries/packages). I used pip3.6 to install these, since the default python install is 2.7.9 on the OS.
Please let me know if there is more information needed. Thanks!

Have you tried checking whether you're using python 3.6 instead of the 2.7? Try checking your bashrc.
I had a similar problem before with seaborn because i was using 2.7 at first and changed to 3.6. I used spyder now so my default python and projects will not get confused. Or you could try Python Virtual Environment.

Related

Trying to download a matplotlib module from cached data but it's not working

So basically I don't know how to use pyenv so i just download modules directly. This time I was trying to install matplotlib when I interrupted the process by CTRL-C since it was just showing the progress bar at full but doing nothing.
Then I tried to install again, with pip3 install matplotlib.py.
It ran the cached-matplotlib. Then this happened.
I've tried uninstalling it but it doesn't exist, I've also tried restarting my laptop but it didn't do anything.
I've searched online for the past 1 hour now and no answer at all.
If there's really no way then I guess I'll trying using pyenv(that's what it's for right?).
(I use pip3 because my default built-in python is python2)
Any help is appreciated.
I can see that you are using python 3.9 version. According to matplotlib 3.3.3 the pip command doesn’t support this version yet as of today. So, downgrade your python version to 3.8 may solve the issue. Also, using pyenv to manage your python version would save you those issues in the future.

How can I run matplotlib in Pycharm on macOS?

I can run code through terminal and have a matplotlib window pop up with the graph but not through Pycharm. All I get is an error saying:
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
I'm not sure how to install Python as a framework or what that really means. I've googled about but I don't want to mess my system up.
Can someone offer a solution at least of what I should be trying to do or what to google around for.
Sorry if I lack some of the technical language/knowledge to explain this problem. Thanks
macOS High Sierra 10.13.1
If you install matplotlib with pip, or conda, you should have a directory ~/.matplotlib.
Inside that directory create, or open if it already exists, a file called matplotlibrc.
To make TkAgg the default backend just add the line backend: TkAgg
I found a short term fix until I can make changes to the necessary files from user Iron Pillow.
import matplotlib
matplotlib.use('TkAgg')
I just insert this before I import any matplotlib subpackages.
I encountered a similar situation that a graph report library based on matplotlib works fine on Conda, Jupyter, but not in Pycharm. It can generate a multi-page pdf. But when I run a program that calls the report library inside Pycharm on MacOS, and the pdf can not be generated properly.
My python 3.6 installation is from Anaconda. I found two solutions. First solution is to run pythonw from a terminal. This is obviously outside of Pycharm, and is not as convenient as you wish.
The second solution is to add "backend: TkAgg" to matplotlibrc.
This file can exist in several places. If this change is meant to be personal, then this file can live under ~/.matplotlib. You can even add this file in the current working directory, to make it part of the program you run.
This is the least intrusive solution without having to add python code that breaks platform compatibility. Formal documentation can be found in the "The matplotlibrc file" section of https://matplotlib.org/users/customizing.html
You just have to install python. You can do that using Homebrew.
In a terminal run:
sudo brew install python

How do I change the kernel/python version for iPython?

I have installed iPython using pip in OS X 10.10, and it gave me the "ipython" and "ipython2" commands, which run great, but which use OS X's default python version 2.7.9. I downloaded and installed the latest release of Python3.4 and can load it with the command "python3," but cannot find a way to get iPython to use this version of python. The iPython Web site states the package can be used with python versions 3.3 and above, but I cannot find any instruction on how to change the default python version used.
So far I have found that the jupyter package for iPython has a kernel specification in /usr/local/share/jupyter/kernels/, which is just a folder called "python2" containing a json file that points to the system's python 2.7.6, but altering this to point to the new python3.4 installation does not work. My guess is this configuration is for the ipython notebook.
I've also tried the approach here: ipython reads wrong python version
In doing so I've duplicated the ipython2 command in /user/local/bin/ and edited it to use the python3 interpreter located at /Library/Frameworks/Python.framework/Versions/3.4/bin/python3, however, this gives me an error "ImportError: No module named 'IPython'," which suggests the python3 installation does not have ipython installed.
To tackle this, I've tried uninstalling ipython and reinstalling it using pip, but it just targets the system's Python 2.7 installation and does nothing for python3.
Does anyone know how to configure iPython to use a different python version, or even install a separate ipython installation for python3? Ultimately it would be nice to quickly switch back and forth depending on my needs.
I just found the answer. In essence, this stems from not understanding the python installation layout and how resources are separated between installed interpreters. It appears each python version will have its own repository of tools, and the current "pip" command I had installed on the system was mapped for use with python 2.7, so all libraries, tools, and other details it managed where available only to python 2.7. This included iPython.
I thought that installing python3 would make all these libraries available to the new interpreter by default, but it appears the system keeps them all separate (which makes sense). The main issue here was continuing to use "pip" which targeted the old installation, instead of the new "pip3" command included with python3. By using pip3 to reinstall iPython, I was able to get iPython3 installed properly.
Unfortunately this setup means needing to re-download other libraries, but that's not too difficult.
It might seem like a trivial issue in hindsight, but this had me completely stuck. I hope this helps someone else in this situation.

How to uninstall and/or manage multiple versions of python in OS X 10.10.3

I have installed the Python IDE Spyder. For me it's a great development environment.
Some how in this process I have managed to install three versions of Python on my system.These can be located as following:
Version 2.7.6 from the OS X Terminal;
Version 2.7.8 from the Spyder Console; and
Version 2.7.9rc1 from an IDL window.
The problem I have is (I think) that the multiple versions are preventing Spyder from working correctly.
So how do I confirm that 2.7.6 is the latest version supported by Apple and is there a simple way ('silver bullet') to remove other versions from my system.
I hope this is the correct forum for this question. If not I would appreciate suggestions where I could go for help.
I want to keep my life simple and to develop python software in the Spyder IDE. I am not an OS X guru and I really don't want to get into a heavy duty command line action. To that end I just want to delete/uninstall the 'unofficial versions' of Python. Surely there must be an easy way to do this - perhaps 'pip uninstall Python-2.7.9rc1' or some such. The problem is that I am hesitant to try this due to the fear that it will crash my system.
Help on this would be greatly appreciated.
(Spyder dev here) There is no simple way to do what you ask for, at least for the Python version that comes with Spyder.
I imagine you downloaded and installed our DMG package. That package comes with its own Python version as part of the application (along with several important scientific packages), so it can't be removed because that would imply to remove Spyder itself :-)
I don't know how you installed IDL(E?), so I can't advise you on how to remove it.

numpy python 3.4.1 installation: Python 3.4 not found in registry

I have two python versions on my computer 2.7 and 3.4.1 . I have tried to install numpy by pip3.4 which resulted with vcvarsall.bat not found which i am pretty sure it is included in system path. Then i gave up downloaded numpy binary numpy-1.8.1-win32-superpack-python3.4.exe. And during the installation it tells me that numpy cannot find python 3.4 in the registry which i see that it is there also.
HKEY_LOCAL_MACHINE
-SOFTWARE
--Python
---PythonCore
----2.7
-----Help
-----InstallPath
-----Modules
-----PythonPath
----3.4
-----Help
-----InstallPath
-----Modules
-----PythonPath
so what has left me to do from here? My system is windows 7 64 bit.
There is an easier fix, remove and re-install python, in the beginning of python setup when you are asked if you want to install python for all users or just this user, select this user only.
That way the registry goes into current user by default and can be found easily by successive software packages. Tried it myself, worked like a charm.
Just a simpler option for technologically less literate people like myself.
But if you need it for multiple users on a PC then you have got to edit the registry and put it in manually, from local machine to current user. Copy it like explained in previous comments.
When installing numpy on Windows you have to ensure that you are using a .exe for the corresponding Python installation.
As you're using Python 3.4.1 you have to use an installer for Python 3.4.1. The installer that you were using was last modified on 25th March which is before 3.4.1 was released. This suggests it was for 3.4.0 and so will not work.
If you need up-to-date Windows installers for numpy (as well as a large host of other packages) they can be found here.
This steps work for me with windows 8.1 64bits
The problem is that some module installers look in the wrong place for Python version information.
For example, in the case of this one module, the installer was looking for HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.4 in the registry.
I found that my Python 3.4 installer had placed this information in HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.2 instead.
Once you know the reason, solving it is easy.
Open Registry Editor (may need administrator privilege) and export HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.4 into a text file.
Open the exported .reg file in a text editor and replace the HKEY_LOCAL_MACHINE entries to HKEY_CURRENT_USER.
Add these new entries back to the registry (here is how).
The module installer should now be able to proceed without throwing the error.
ref: http://codeyarns.com/2012/04/28/python-version-not-found-in-registry-error/
I have just faced a similar issue ("numpy cannot find python 3.4 in the registry") when installing numpy-1.9.1-win32-superpack-python3.4.exe. The solution was to install the python-3.4.2.msi instead of python-3.4.2.amd64.msi.
You are trying to install the 32 bit version of numpy on a 64 bit installation of python. It doesn't look to me like you can download 64bit scipy from sourceforge so a solution is to install a 32bit version of python.
Abilio Faria gave the answer. Another answer in another thread over here
I think the changing of the registry works quite well.
Worked wonders for me... quick fix:
http://codeyarns.com/2012/04/28/python-version-not-found-in-registry-error/

Categories