python 2.7 not installing matplotlib - python

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!

Related

Does installing Python also install libraries like scipy and numpy?

I just got a new computer, and I was installing some Python libraries. When I tried to install numpy, I got a message on the console saying numpy was already downloaded. I went into the library folder, and not only was numpy there, but scipy, matplotlib, and a bunch of other libraries as well. How is this possible, considering this computer is brand new? I had installed Python the previous evening, so does installing Python automatically install these libraries as well?
It depends on which Python package you install.
On any desktop oriented Linux distribution, installing the Python package will only install Python. And in practice, it is generally already installed.
On Windows (and perhaps OS X), you need to pick a Python bundle somewhere. Perhaps did you choose Anaconda, which AFAIK installs a lot of common Python libraries (as opposed to its light version Miniconda).
Python does not ship with these libraries unless you are using a pre-packaged distribution such as Anaconda.
If you copied your data from your previous computer to this one, you may have copied the python installation (and thereby the libraries you had installed before) in your appdata folder.
Another possibility is that you have install Anaconda, which is targeted especially at scientific things, and comes with numpy, scipy and some other things preinstalled.
Although this is not the place for these types of questions, yes, there is no need to install libraries, as most of the times when you download Python in a distribution, such as Anaconda, they are also included.

Is it possible to use custom build cpython in Anaconda environment?

I build a cpython locally (Windows) with a fix to a problem with multiprocessing that I have, but I also need data science stack of packages like numpy, pandas, scipy, matplotlib, statsmodels and few others. When I try to install them the process appears quite cubersome for many packages and for scipy I wasn't able to resolve it after 3 days of trying.
I was thinking that it would be amazing if I can just replace python in my anaconda env, and use conda to install the packages I need. Is it possible to easily replace python with binaries I have or I need to wait while my fix is released with new Python version?
I was able to resolve my issue by replacing only python DLL that I had in, and the conda environment just worked with it

NumPy module not found after install

So after numerous attempts at installing NumPy, all seem to have gone well until I boot up PyCharm and import numpy. It throws the "Module not found" error with just a single line of code, being:
import numpy as numpy
It's getting fairly frustrating, after installing numpy through pip, downloading the .whl and manually installing it, and even somehow bricking my computer by repairing python 3.6. I've got no idea as to what I'm doing wrong. Help would be greatly appreciated.
Without knowing exactly what you have installed in your computer, it can be a bit tricky to troubleshoot it. However, you have to be aware that you can have multiple Python installations in your computer. It is quite common to have Python2.X and Python3.X side by side.
When you used pip to install numpy, you installed it for a specific Python interpreter (sometimes you have pip2 and pip3 in your system, for example). And then, when you use PyCharm, it may be grabbing the wrong Python interpreter. You can go to File/Settings/Project and you will find something like the window below:
You will see that you can choose your interpreter and it will give you the list of all installed packages. I suggest that you check that you have numpy listed.
Moreover, from the same window you can install the packages you need; just click on the green + sign at the right of the screen and search for numpy and follow the needed steps.
Pro Tip: You should definitely consider using virtual environments, which are entirely supported by PyCharm.

Having troubles installing GDAL for Python

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.

What version of scipy and matplotlib should I install on Mac Mountain Lion?

I wish to install python numpy, scipy, and matplotlib packages. I used the following:
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose
I was able to install and run numpy, but not scipy or matplotlib. I get an error, "No module named scipy", even though installation appeared to proceed normally. I suspect that this has something to do with the version of scipy and bumpy. I am running OS X Version 10.8.4, python 2.7.2 and numpy 1.6.1. I suspect the problem is either the version or the directory which scipy is installed; scipy is in /Users/myname/src/scipy. I couldn't find out where numpy is located (how can this be done? Spotlight search does not indicate file directory, and grep hangs). How can I install scipy and other packages?
It's hard to be 100% sure without a little more information, but I'm 99% sure…
Your problem is that you're installing all this stuff for the MacPorts Python, but then trying to run Apple's Python, which doesn't have any of it installed. (Part of the reason I suspect this is that Apple's Python is version 2.7.2, while MacPorts has been on 2.7.5 for a long time now. The other part of the reason is that this is exactly the same kind of problem people have when they install two different Python X.Y versions without realizing that's what they're doing.)
If you want to use the MacPorts Python, run /opt/local/bin/python instead of just python.
If you know what you're doing, you can change your PATH, or create a symlink, etc., but I suspect you will just confuse yourself further.
I personally think you'd be a lot happier just sticking to Apple's Python. You need to install a Fortran compiler with MacPorts (or Homebrew, or manually, or …), but to install Python packages, just use pip.
(At this point, that last bit of advice probably won't help you, as the first pip on your PATH is probably the MacPorts one, and doesn't match the first python on your PATH. But if you're willing to start over, just port uninstall python, and then look at these blog posts or the dozens of related questions here on SO.)

Categories

Resources