Okay so I tried to install matplotlib and python earlier from the command line. Turns out i probably already had python installed but it was not make(ing) plots. Then that didn't work so i tried to, from the software center install matplotlib. So my software center says it is installed. However, when i am in python it still can not find matplotlib. Also when i am not in python and try to run commands like
python setup.py clean
It says python cannot find setup.py
This has been going on for hours and i am a beginner linux user and it is horrible
From the command line you can install matplotlib as follows:
$ sudo apt-get install python-matplotlib
Once it's installed you can access it from inside python like this:
>>> import matplotlib
>>> help(matplotlib)
If you want more control over the version of python you're using, I recommend using Anaconda. Very easy to install and use.
If you want even more control you can build from source. That post is specifically about setting up IPython but the python build step are the same.
Related
Currently trying to get python up and working on my work laptop which has proven to be a huge pain in the you know what.
It seems like the PATHing is all screwed up even with pip installing packages. For example, I tried to install seaborn today via pip install seaborn which ran successfully but when I try to import it on Visual Studio it has the yellow squiggly underneath it. I try to reinstall it but it says it has already been satisfied.
Is there anyway to manually re-route all of my python libraries to where I actually know whats going on? I have the PATH set to the correct library in environment variables but it still does not read that I have seaborn installed.
Any help is greatly appreciated.
You can create python virtual environment and install your libraries on it.
https://linuxize.com/post/how-to-create-python-virtual-environments-on-ubuntu-18-04/
It creates a isolated area for your specific project.
It sounds like you might have different python installations on your system.
If that's the case it might also be the case that the python you are using in visual studio isn't the python that is packages are being installed for via a straight forward pip command.
You could try to instead of pip install ... call python -m pip install .... That ensures that you are using the pip of the python installation
I recommend you to install all dependencies (seaborn, pandas, numpy, matplotlib, etc) in a virtual environment, that means that you can have its own independent set of installed Python packages in its environment.
See here the python documentation on how to work with virtual environments on different OS.
Also, check which python versions you have installed on your machine. If you have both python2 and python3, use pip3 and python3 on terminal whenever you want to install or run something.
How do I download and install matplotlib for Python 3.5 for my mac to use in Eclipse? My mac is running macOS High Sierra version 10.13.1. I can handle quantum mechanics and thermodynamics, but the whole downloading and installing and using new python programs/packages/libraries/stuff is so hopelessly confusing to me. Assume I don't know anything, because I don't.
For scientific work using Python I recommend using Anaconda. It has all relevant packages installed.
Follow these steps:
Download Anaconda
Double Click the File in your Download Folder
For further setup with Eclipse, follow these steps.
Given that you have Python3 already installed you could also try:
python3 -m pip install matplotlib
In my experience, it is wise to consider installing a package manager like Anaconda. For something like matplotlib however, using
pip install matplotlib should be more than sufficient. For your information, the Mac already has pip (a package management system) installed, so running the above command should be enough.
I'm trying to teach myself python, and I feel out of my depth. To start, I am working on a mac which already comes with python 2.7 installed.
I installed python 3.6 recently and have been using it to teach myself the basics. I'd like to eventually learn how to produce mathematical plots in python, and I know I will need the matplotlib package to do that.
Following some advice online, I was told that python3 already comes with pip installed, which is what I thought I should use to install matplotlib. The advice said I should type the following into the mac terminal:
python3.6 -m pip install matplotlib
I typed this, and it seemed like the package was installing, but I ended up getting some sort of error code that said:
Command "python setup.py egg_info" failed with error code 1 in [folder].
I tried opening IDLE and typing "import matplotlib", but I got the error: "no module named matplotlib". I also tried typing "import matplotlib.pyplot as plt", but I got the same error.
Based on further research and this youtube video, I've decided to just install miniconda in order to have access to the matplotlib package.
The problem is, I'm not sure if I should somehow be uninstalling whatever was installed when I ran the code above to install matplotlib. I've actually run that line of code 3 or 4 times. Should I remove anything before installing miniconda? Also, I am running python 3.6, while miniconda is listed on the website as being for python 3.5. Does this mean it won't work for my version of python?
Running pip like that would install packages system-wide. I'm guessing it's failing because you're not running as root (i.e. the administrator user). But wait! Don't try again as root! Instead of installing packages, do it in a virtual environment. First create it:
virtualenv myenv
This creates a directory called myenv with a bunch of stuff in it (so make note of where you run this command). Whenever you want to use the virtual environment (like straight away!) you first need to activate it:
. myenv/bin/activate
Don't miss out that dot (followed by a space) at the beginning! As the other answer says, the first thing you should do in it is upgrade pip:
pip install --upgrade pip
Now you're ready install whatever else you like:
pip install matplotlib
One last note: The virtual environment is tied to a particular Python version. By default it uses the system's Python 2.7 installation, so to use a different one you need to specify it when you create the virtual environment, like this (if that Python version is installed system-wide):
virtualenv -p python3.5 myenv
Or like this (if that Python version is not installed system-wide):
virtualenv -p /path/to/my/installation/of/python3.5 myenv
While the virtual environment is activated, you don't need to specify the particular path/version of Python. Just run it like this:
python
I also encountered many problems during my installation.
It seems that version 2 of matplotlib is not compatible with Python version 3.
Finally, I succeeded by specifying version 3 of matplotlib as follows with the following command:
sudo apt-get install python3-matplotlib
Reference from the Matplotlib website:
https://matplotlib.org/users/installing.html#building-on-linux
Try upgrade setup tools
--upgrade setuptools
or
easy_install -U setuptools
or upgrade pip
pip install --upgrade pip
I ended up downloading anaconda and using the python interpreter that comes with it, as anaconda comes with matplotlib and many other python packages of interest.
the pip command typically is for the Python 2. use pip3 instead to install the libraries in the python 3.X path
This should work
pip3 install matplotlib
The solution that work for me in python 3.6 is the following
py -m pip install matplotlib
Matplotlib files are downloaded in ~/.local/lib/python3.6/site-packages/ and not in /usr/lib/python3.6/ .
Try the command:
sudo cp -r ~/.local/lib/python3.6/site-packages/* /usr/lib/python3.6/
I recently formatted my hard drive and got rid of Windows and went to Linux. I had a program that used to work fine before the reformat but isn't working fine now.
I believe it was written for 3.4 and not 2.7 since I used import tkinter and not import Tkinter. In either case the program won't run now that I have made the switch over. In 2.7 it does nothing...it acts like it has run through the code and then stops and gives me back the cursor when it should be popping up a t/Tkinter window displaying a graph. In 3.4 I get the error saying numpy isn't installed.
When I apt-cache policy python-numpy it comes up showing it 1:1.8.2 is installed. When I do the same for scipy it shows 0.13.3 is installed. Seeing from other websites when I check for cython it shows 0.20.1+git90-gee6e38e is installed. When I check for tk it comes up 8.6.0 is installed.
I'm a bit lost. Why I do get the error code saying numpy isn't found when I got to run the program yet it is installed. What do I have to do to get this program back up and running again.
I think you have the librairies installed for Python 2... Did you use pip to install the librairies ?
Try :
pip3 install numpy
And same for your other librairies.
If you use Ubuntu then you have 2 versions of python executables - python and python3. So I think you need to install dependencies for python3 version by sudo pip3 install numpy or sudo apt-get install python3-numpy if it exists in repos.
from this site
http://matplotlib.sourceforge.net/users/installing.html#installing-from-source
tell us that the requirement is python 2.4 or later but not python3.
Now im working with python3 and i need some plot form matplotlib.
So how to solve it?
I'm sorry, but at the current time it's not supported.
If you feel brave, you can try with the Py3k SVN branch which reportedly works with a simple example. Be aware that there has been no update in the last 8 months on this though.
Of course, you'd be more than welcome to contribute to the porting to Python 3 if you could.
You could try the unofficial versions. Check this site:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Looking at the docs at the link it says the following is a dependency:
Python (>= 2.7 or >= 3.4)
You can download a version of Python that will work at:
https://www.python.org/downloads/windows/
I would go with the most recent release and a 64 bit version as certain libraries for data analysis do not run on the 32 bit version of Python.
The version of Python you download will come with pip which you can then use to install any libraries you need to do your work.
Make sure you have set your environment variables if you want to run your programs from the command line or bash terminal.
I installed matplotlib through the bash terminal with:
pip install matplotlib
Let me know if that helps.
To install matplotlib on windows, first, you have to install pip first to install pip on windows go to website
https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip
Download get-pip.py, being careful to save it as a .py file rather than .txt. Then, run it from the command prompt:
python get-pip.py
if pip is already installed, install matplotlib by writing in command prompt:
python -mpip install -U pip
python -mpip install -U matplotlib