python: installing matplotlib locally - python

I am a user without root privileges on a linux multi-user platform. I would like to install matplotlib (I have seen some questions on stackoverflow but they are old and related to previous versions of matplotlib). I think the thing I should do is installing from source python -mpip install .. I cannot find any way to install locally and not globally, as I don't have superuser privilege.

You can take a look here, on stackexchange the problem were solved.
As you can read:
Download the matplotlib and install it manually
install it using pip or easy_install
Manually:
cd /dir/of/your/downloaded/lib
python setup.py install --user
With pip or easy_install:
pip install --user matplotlib
easy_install --prefix=$HOME/.local/ matplotlib

If you have pyenv installed on the system you can easily switch to another python environment that has matplotlib installed.
For example, you can install the latest version of anaconda python, using tab key autocompletion to see which versions are available.
pyenv install anaconda3-5.2.0
Then you can switch your local python version using
pyenv local anaconda3-5.2.0
Now you can check your python version and matplotlib should be available.
On the other hand if pyenv is not currently installed, either ask your admin to install it or use a workaround script as described here.

Related

Installing python packages on anaconda on macos

This may be a silly simple question, but I couldn't find an answer in the documentation of Anaconda or elsewhere. I am a bit of a noob when it comes to Python and I am trying to install a package. The problem is generalizable to other packages.
specs
I am working on a macOS Catalina (10.15.5) and using Anaconda as my python environment (python2.7).
problem
I am attempting to install the package pyLDAvis in my python environment, but the package isn't available on Anaconda's environment manager, and pip or conda install isn't working on the Spyder shell. Do pip and conda installs only work on the Anaconda Prompt? The problem is that I have read that the Anaconda Prompt only exists on Windows, and I am on mac. How could I install packages (pip, conda, or else) on Anaconda?
Am I missing something?
Any help or pointers to documentation would be great! Thanks
Assuming you have conda already installed and your shell is properly configured, you can activate the base environment via
conda activate
You can also create a new environment, see manage-environments docs.
For more information than given below, see manage-pkgs docs.
In case of conda, after your environment is activated, you can then install a package via conda install <package name>, e.g. the package numpy
conda install numpy
In case of pip, after your environment is activated, you can then install a package via pip install <package name>, e.g. the package numpy
pip install numpy
I only do this if the package is not available via a conda channel.
If the package is also not available via pip, you can download the source and set the package up your self. Usually the package author describes how to set up his/her package.
Thanks Stefan for the suggestion! I struggled a bit because although conda was "already installed", my shell was indeed not "properly configured." I am writing here my solution because it may be a recurring theme for macOS users and had an easy fix.
Starting with macOS Catalina, macOS uses zsh and not bash as the default shell, and so calling conda on zsh had no effect. The error message was: -zsh: conda: command not found. I solved this by changing the default shell to bash by running the following command: chsh -s /bin/bash.
Now that the shell and conda are properly configured, I managed to use conda activate as you suggested Stefan.
Finally, the package pyLDAvis could not be installed by conda install pyldavis but was installed with pip install pyldavis.
Solved!

Install Python module easygui on Ubuntu 16.04 without Pip or setup.py

I am new to Ubuntu coming from Windows. I need to install the easygui Python module but the version currently on PyPI has issues. The previous release 0.97 is fine. Using pip install easygui installs 0.98. I can download the 0.97 library from SourceForge and I want to install it on Ubuntu 16.04. The download does not have a setup.py file (which I get how to use to install libraries). In Windows I could copy the easygui.py file to the Libs directory and call the module. Where do I put this file in Linux 16.04? The file structure is confusing for me.
You can use pip to specify the version of the module you would like to install:
pip install easygui==0.97
You could also tack on the flag --force-reinstall if you run into trouble with the module being installed already.
as a side note: This might be a good time to start using virtual environments.
If you have easy_install working, you could try:
"sudo easy_install easygui"
or if you want to specify the location or if you do not have the root privileges:
"easy_install --install-dir=here-some-folder-where-to-install easygui"
If you want to install some specific version of the tool with the easygui, perhaps this post helps:
Install particular version with easy_install
At least "sudo easy_install easygui==0.97" worked for me.

brew python versus non-brew ipython

I installed python via brew, and made it my default python. If I run which python, I obtain /usr/local/bin/python. Also pip is installed via brew, which pip returns /usr/local/bin/pip.
I do not remember how I installed ipython, but I didn't do it via brew, since when I type which ipython, I obtain /opt/local/bin/ipython. Is it the OS X version of ipython?
I installed all libraries on this version of ipython, for example I have matplotlib on ipython but not on python. I do not want to re-install everything again on the brew python, rather continue to install libraries on this version of ipython. How can I install new libraries there? For example, Python Image Library, or libjpeg?
If possible, I would like an exhaustive answer so to understand my problem, and not just a quick fix tip.
I installed python via brew, and made it my default python. If I run which python, I obtain /usr/local/bin/python.
Okay, good so far.
Also pip is installed via brew, which pip returns /usr/local/bin/pip.
Actually, not quite brew install python would have installed pip because even doing brew search pip comes up with this warning.
If you meant "pip" precisely:
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
https://pip.readthedocs.io/en/stable/installing/
So, Python came with pip, not brew install
when I type which ipython, I obtain /opt/local/bin/ipython. Is it the OSX version of ipython?
There is no "OSX version of ipython"...
I installed all libraries on this version of ipython, for example I have matplotlib on ipython but not on python.
You actually did install them to your brew installed Python. IPython is not a new installation of Python.
You can even start a python interpreter from the terminal and import matplotlib to check this
I do not want to re-install everything again on the brew python
What exactly needs re-installed? It's already installed into the brew python
To transfer all your packages you can use pip to freeze all of your packages installed in ipython and then install them all easily from the file that you put them in.
pip freeze > requirements.txt
then to install them from the file pip install -r requirements.txt
I'm not entirely sure if I understood what you're asking so if this isn't what you want to do please tell me.
OK, so I solved by uninstalling macport (and so the ipython I was using, which was under /opt/local/bin) and installing ipython via pip. Then I re-install what I needed (e.g. jupyter) via pip.

How to install theano library on OS X?

In my machine learning course we are going to start using theano, a very well known library for deep learning architectures. I all ready installed it with the following command:
$ pip install Theano
By the way, when i want to test if it installed correctly, the python interpreter canĀ“t fin the module. I dont know if im installing it right. Reading the documentation i found anaconda, is it right to first install anaconda and then try to install again with pip theano?. Is this the right way to install this library on MAC OS X?. How can i install this library correctly in order to use theano succesfully?
Installing Python with Homebrew and installing Theano with pip after that worked fine for me. I just needed to install nose after that to be able to run the tests.
brew install python
pip install Theano
pip install nose
I cannot help much installing the framework with Anaconda though.
Anaconda is indeed highly recommended for python libraries. In fact, Anaconda is not only for python in contrast to pip. You can read more here: What is the difference between pip and conda?
For installing Theano, I had already installed Anaconda. I just simply did:
conda install theano
Then, in Ipython, I successfully imported theano:
import theano
Consider installing Theano in a virtual enviroment as oppose to installing it globally via sudo. The significance of this step is nicely described here.
In your terminal window, do the following:
virtualenv --system-site-packages -p python2.7 theano-env
source theano-env/bin/activate
pip install -r https://raw.githubusercontent.com/Lasagne/Lasagne/v0.1/requirements.txt

Python - No pip when creating a virtual environment

So I heard about the proper way to install packages into python by creating a new virtual environment for every project. Being on a mac (10.8) I have installed python3 using Homebrew, then I installed pip and virtualenv on this copy.
Now here comes the problem:
I create a new virtualenv, and activate it using:
virtualenv testing
source testing/bin/activate
When I type
which python
/Users/mik/Desktop/testing/bin/python
But typing
which pip
/usr/local/bin/pip
(learned of this when trying to install a package in the virtual environment, and it installed in the system wide installation in /usr/local/)
Inside the folder testing there is no file referring to pip
Extra Question: How does pip know which python to install the files to, for example pip list (which I believe refers to python 2.7) outputs the names of packages installed on python 3.3
I'll start with the last question as it explains what is happening.
The commands pip and easy_install are python scripts which are made executable on the filesystem. The python they use is the python that the first line tells to run the script. e.g. in /usr/bin/easy_install it is #!/usr/bin/python This will be Apple's python. So easy_install will install the 2.7 version of pip and virtualenv and will ignore your python3.3 setup.
The way to instal into python 3 is to install the 3.3 version of pip and virtualenv, the easiest way would be to install the Homebrew package for them. I think it is easier and less confusing to use just one package manager (Homebrew here) and not two (i.e. Homebrew and python).
You can also install easy_install directly. The way to do this is install the distribute package using python3.3 explicitly.
Python 3.4 will make this much easier as pip will always be available

Categories

Resources