I'm currently running Matplotlib 0.99.1.1 on Ubuntu 10.04 LTS (Lucid Lynx).
I would like to upgrade Matplotlib to version 1.1.0. I have tried following the
instructions at SourceForge, which didn't seem to do anything (IPython still thinks I have version 0.99.1.1).
I have tried searching for how to do this another way but, being relatively new to Linux, am a little confused what I need to do now. I have tried a few suggestions on the forums but still I cannot seem to install Matplotlib-1.1.0
This thread for example doesn't seem to work for me (pip complains of an "Unknown or unsupported command 'install'").
Any help is much appreciated!
Unless my memory fails me completely, I followed the build from source instructions you link to on two Lucid systems of mine. These instructions, to be precise:
http://matplotlib.sourceforge.net/users/installing.html#installing-from-source
Worked like a charm, after I remembered to do python setup.py install. And, yes,prior to the install, I removed the 0.99 matplotlib via synaptic. Did you try removing the older version first?
https://launchpad.net/ubuntu/oneiric/+source/matplotlib
There is a section for binary builds, just grab the appropriate package for your system architecture and dpkg -i the_package_name.deb
I'm not sure what went wrong with my system, but the issue resolved itself. Either one of the procedures I followed while searching for an answer worked, or the build from source instruction worked.
Perhaps my computer just took a while to realise I did in fact have the newest version installed.
For future reference, I would follow the install from source instructions on the matplotlib site at SourceForge, noting the answer by Zhenya.
Related
I have just downloaded PyTorch with CUDA via Anaconda and when I type into the Anaconda terminal:
import torch
if torch.cuda.is_available():
print('it works')
then he outputs that; that means that it worked and it works with PyTorch.
But when I go to my IDE (PyCharm and IntelliJ) and write the same code, it doesn't output anything.
Could someone please explain to me how I can somehow get this to work in the IDE?
It was driving me mad as well... What finally helped me was the first link that says to use PyCharm "Terminal" to run the pip install command (from the PyTorch website). That fixed all my problems. (I had installed pytorch 3 times by that time and tried different interpreters...)
https://www.datasciencelearner.com/how-to-install-pytorch-in-pycharm/
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio===0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
I hope this helps save someone hours of headache. :)
I also spent over 10 hours trying to figure out what was wrong. I ended up checking if there is something wrong with interpreter.
What was the problem is version of python (I had v. 3.8). After upgrading to newest version, problem was solved.
Check your version using command:
python --version
If your version is old (current is 3.9.2), install newest one from official python site:
https://www.python.org/downloads/release/python-392/
After installation make sure you using newer version (use command above)
I had a similar issue.
Inspired by #the-lay answer, calling import os; os.system('') resolved my issue.
Another possible root of the problem is running a Flatpak version of Pycharm. Took me some time to figure out, but Flatpak does not load user specific environment variables files (i.e. ~/.profile, ~/.bash_profile and conda environment). I have deleted Flatpak version and installed a snap version (sudo snap install [pycharm-professional|pycharm-community] --classic) and it loads the proper PATH which allows loading CUDA correctly.
Over the last few days of headaches, I've found 3 possible methods to do this, all of which have issues.
PyGObject's pip install fails due to a lack of Cairo and probably other dependencies. While this would be my preferred method, it would probably be the hardest to fulfill.
Using MSYS2 allows me to use GObject through the mingw64 python, but using pip to get my other modulues such as pylint fails. I'd like to have an MSYS2 or similar install on my system anyways to make some windows binaries, so I'm very open to this as well.
EDIT: Got pip to work in MSYS2. Make sure to sync toolchain with pacman.
PyGObject for Windows seems messy at best and isn't up-to-date. Would require having a second python installation anyways, giving no benefit over MSYS2.
Note I'm a complete newbie to Unix and have little experience with CLI's in general, so any help regarding MSYS2 will need to be explained as if to a child. My only other experience with this stuff involved an endless cycle of hell that was installing Arch to a separate partition, breaking said install, then reinstalling again.
I also tried Cygwin, but I couldn't get that to run Python with GObject at all with my "install all the needed packages then pray" method. Creating a Gtk.Window() caused the terminal to use none of the memory it had and explode.
MSYS2 is currently the only "officially" supported way: https://pygobject.readthedocs.io/en/latest/getting_started.html#windows
pip in MSYS2 should work in general, if something doesn't please file a bug at https://github.com/Alexpux/MINGW-packages/issues .
As you said in the third alternative to install a new Python version, you can create and run multiple Python versions using pyenv. You can go through the installation section of their Github repo for installation and an overview: https://github.com/pyenv/pyenv/
For a comprehensive guide on how to use it, you read this amazing post by Real Python:
https://realpython.com/intro-to-pyenv/
I am still pretty new to python, and I was wondering if anyone has had this problem before. I have read other threads, but I haven't seen this problem addressed yet. I need to install the GDAL module for python, and I have seen threads saying you need to install GDAL first and then it can be used on python, but I have also see others that said that conda install GDAL is enough. When I try the latter, I get this error. Any ideas?
I had the same problem two days ago trying to install GDAL on Debian Jessie.
The solution was using pygdal python package from PyPi.
Just read the instructions at PyPi and follow them, they are a bit different then one expects. In general:
install required dependencies into your system (e.g. using apt-get install libgdal1-dev
check, what version of GDAL is installed
use pip to install pygdal with a version matching the installed GDAL lib.
The last step is a bit unusual, but does the trick.
This works for Linux. For Windows my colleagues claim, there are ready made binaries, which can be installed.
I am trying to install py2cairo on a framework build (Mac OSX Lion) of python 2.7.3 using brew. I have been unsuccessful this far.
First, I tried a simple
brew install py2cairo
This seems to work only on a non-framework build of python. When I do this on my framework build python faults as soon as I import cairo with an incompatible binary error.
Second, I have tried to build it myself by grabbing it from github and issuing:
python waf configure
This fails with:
Checking for library python2.7 : not found
Checking for library python2.7 : not found
Checking for library python2.7 : not found
Checking for library python27 : not found
Checking for program python2.7-config : /usr/local/Cellar/python/2.7.3/bin/python2.7- config
Checking for header Python.h : Could not find the python development headers
The configuration failed
(complete log in /Users/tobin/tmp/py2cairo/build_directory/config.log)
I have tried everything at: How to install PyCairo 1.10 on Mac OSX with default python but none of this has helped.
It appears to me that this may be failing to find python2.7 library and header file since it is a framework build. Is that possible? I was looking at the brew formula and it appears that framework builds do not get --enable-share set at build time. I'm not sure if that is relevant here - but maybe one possibility.
Anyone other insights would be great. Thanks in advance.
UPDATE:
I discovered that the inability to build py2cairo had to do with the use of the "-march=native" flag by gcc. gcc (4.2.1) on Mac OSX has issues with this. I then reinstalled gcc as well as python. Afterwards when building py2cairo with waf - it was getting "-march=core2" and everything built.
Unfortunately, not all is good yet. I get the same error when I import cairo from my build that I got from the brew version (as mentioned above). The exact error message is:
>>> import cairo
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap: 6
and then python exits.
It would now seem that the issue is related to the framework build of python. I tested it without a framework build and it worked fine.
So as to not leave this question dangling ... I wanted to follow up with my resolution and learning points:
As noted above there was an incompatibility with my version of OSX and a gcc compile flag called -march=native. In a later version it was coming up as -march=core2. This pretty much fixed itself with compiler/version changes after cleaning up my machine.
For years I have had quite a mess with all of my various MAC OSX installs - and accepting the "migration option". Two machines ago - I installed the python binaries for versions 2.4, and 2.5, Then eventually went to macports for various reasons. Then eventually went to homebrew. When I went to homebrew I tried to clean things up by hand (but of course this can be challenging). To make matters worse - everytime I have gotten a new mac (2 times) in the last 6 years I take "the migration install" option and this pushes the mess forward and makes it worse. So as I started looking into things further - I had various installs of python, with different versions - mac-native, python-native, mac ports, homebrew, and probably even others too on my system. So my best guess is that cairo was somehow finding one of these and trying to build against it.
I finally solved this by deleting a bunch of old python installs by hand and then starting over with a fresh virtualenv and homebrew install of python 2.7.
WARNING: I don't think that this is the smartest way to go. I was careful not to delete a version of Python that I thought came native with OSX Lion (I think it is 2.6) - but it is not clear how it may potentially effect some other things that may have depended on older mac installs of python. I ended up deleting a 2.3, a 2.4, and two different 2.5s - along with various links in some places. WHAT A MESS! Unless you are absolutely sure of what it is you are doing (which I was not) I would not suggest this approach. I was basically trying to kill 6 years of python install crud that has collected.
To be safe I probably should have started with a fresh OSX Lion install and then added my homebrew version and went from there. I will likely do this in the near future.
Hi I'm trying to install matplotlib on my mac. I have lion OS X.
my python version is 2.7.1 ( this is what it says when I run it from terminal)
every time I install matplotlib, it promots this error
matplotlib 1.1.0 cannot be installed on this disk. matplotlib requires System python 2.7 to install.
I'm new to the python world and I need a tool to graph a few things... so a clear explanation is much appreciated.
Thanks!
You are installing a binary package which is going to expect a specific system python. You are better off building from source.
Just try installing it from pip:
pip install numpy
pip install matplotlib
If you do not yet have pip, you can install it like this:
wget "http://peak.telecommunity.com/dist/ez_setup.py"
python ez_setup.py
easy_install pip
If any of this fails, then follow #Nolen Royalty's guide that he mentioned in the comments
I've tried installing python in various different ways to get numpy, scipy, and matplotlib to all work together, and its a huge pain. Your exact version of python will dictate the version of numpy, scipy, and matlplotlib that will work for you.
By far, the easiest solution I have found is to use the pre-built package Enthought. It takes care of all of those problems with one easy installer. You might get some additional software installed like mayavi (an interactive 3d plotting tool), but its not too much.
If you are a student (or have ever been one since the dawn of email), you can download the entire Enthought package for free here. Or you can visit the Enthought home at www.enthought.com. All you have to do is select the academic license and then insert a email that ends in .edu.
I even think there are free trial versions which should solve the issue. I've never tried any of the trial versions, but even if it is a limited time trial, you should be able to use the trial version, and then see exactly which versions of each package you need to install. Its a little more roundabout, but it should work.
I tried to install numpy, scipy, and matplolib on my Mac Book Pro running Lion many times and they all failed. Nolen's recipe cam pretty close, but some of the matplotlib tests were failing in strange ways. The method that worked for me can be found on the page Installing Python, virtualenv, NumPy, SciPy, matplotlib and IPython on Lion
Since you list you are new to Python, I recommend installing matplotlib with MacPorts. First install macports
http://www.macports.org/install.php
then execute
port install py27-matplotlib
A couple of years ago there were some extra steps, but now it is this simple. You need to make sure you set your environment for the macports python, but that is provided in the documentation.
Have Fun!