Is there a way to install matplotlib offline on linux? - python

I have been trying to install matplotlib on offline linux system without much success.
I have tried:
python2.7 setup.py build
It then tries the following:
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
The same happens with setup.py install.
How can I get it to install without an internet connection?
I use Python 2.7.12

Go to Matplotlib pypi package index and download the appropriate file for your system.
Then use:
$ sudo apt-get install python-setuptools build-essential
$ pip install wheel_file.whl
you might have to use sudo with this command.

Download the matploitdb wheel
"http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib"
Then do,
pip install matploitdb_wheel.whl

Related

How can I install DistUtilsExtra on Python compiled from sources?

I'm working on a Raspberry Pi. For some complex reasons I'd rather not get into, I had to remove Python2 and Python3 from the system, and compile Python 3.9.2 from scratch. Works great.
Unfortunately, now, I need Ansible to configure the system, which requires python3-apt if you plan to use a task that uses the apt module, which I do. python3-apt appears to just be python-apt, which I can install with pip.
Unfortunately, when I try that (pip install python-apt), I get this:
ModuleNotFoundError: No module named 'DistUtilsExtra'
If my python was installed with apt, I could just do:
sudo apt-get install python3-distutils-extra
But that depends on the python packages from the apt repos, so it will install Python from apt, which I don't want.
python3-distutils-extra appears to just be a python package, but I can't seem to find it on pypi. Is there a way to install it without using apt?
Or should I just tell apt to install the package, and ignore installing dependencies?
A possible workaround is to rebuild the wheel from the source code of the apt package
apt-get source python3-distutils-extra
cd python-distutils-extra-2.40
python3.9 -m pip install wheel # You'll need this to run setup.py
python3.9 setup.py bdist_wheel # Create the wheel
python3.9 -m pip install dist/python_distutils_extra-2.39-py3-none-any.whl # Install the wheel

Install package paho-mqtt

I am trying to install paho-mqtt package for my python project. But it gives the error
Error: Python packaging tool 'pip' not found.
I am using ubuntu 16.04 and I am running this command
pip install paho-mqtt
Can anyone tell me is there another way to install this?
Install pip first, if using python2
sudo apt-get install python-pip
or for python3
sudo apt-get install python3-pip
Python uses pip to install various Python modules like request, jsonpickel etc.
So you need to install pip first as said by #Asoul

Can't install pycurl with pip

Can't install pycurl with pip, win xp x32, python 2.7.
here is the log
pip install pycurl
Downloading/unpacking pycurl
Downloading pycurl-7.19.3.1.tar.gz (116Kb): 116Kb downloaded
Running setup.py egg_info for package pycurl
Please specify --curl-dir=/path/to/built/libcurl
Complete output from command python setup.py egg_info:
Please specify --curl-dir=/path/to/built/libcurl
----------------------------------------
Command python setup.py egg_info failed with error code 10 in C:\Documents and S
ettings\User\build\pycurl
Storing complete log in C:\Documents and Settings\User\Application Data\pip\pi
p.log
Following the steps one mentioned above, solved my problem.
sudo apt install libcurl4-gnutls-dev librtmp-dev
pip install pycurl
This is a problem indeed. No need to update pip or easy install as it's often advised, well it won't hurt to update but you will still have the problem until you :
install libcurl4-gnutls-dev librtmp-dev packages
pip install pycurl
Worked the same in Linux
I had the same problem. I was able to install it with easy_install instead:
easy_install pycurl
For easy_install, see setuptools.
Here are easy steps I did to get around this:
Download the wheel of the version you want here: https://www.lfd.uci.edu/~gohlke/pythonlibs/
then you can pip install that like so:
pip install C:\sample\sample_dir\whl_file_downloaded
You should know be able to import in your python files
install pycurl using conda, conda will install all dependencies, Hope it works
conda install -c anaconda pycurl
steps to follow :
brew install openssl
PYCURL_SSL_LIBRARY=openssl LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include" pip install --no-cache-dir pycurl
For Linux Please install the libcurl-devel package and then try. It will work.
So has said by Hai Vu you need to install cURL first.
Here is the dowload page : http://curl.haxx.se/download.html
I suggest you install it in your C:/ directory, or if you already installed it elsewhere copye the curl.exe file to your c:/
When done, you can try it by going to the cmd prompt :
cd c:/
curl "your-curl-request"
If it works then curl is correctly installed and you can install pycurl with pip.

How to download and install the pcapy package with pip?

I know that in order to install a package I need to execute:
sudo pip install package_name
But how can I know what is the name of package - I should give as an argument.
I found in pypi a package I want to install - pcapy:
https://pypi.python.org/pypi/pcapy/0.10.3
I tried:
sudo pip install pcapy
It didn't work...
What is the right way to install this package?
Thank you very much!
That package isn't in the PyPI. There's a page, but the source code is hosted elsewhere for some reason (this is the first time I've seen it):
Ubuntu has a (probably old) package:
$ sudo apt-get install python-pcapy
You can also build it from source:
$ sudo pip install "http://corelabs.coresecurity.com/index.php?module=Wiki&action=attachment&type=tool&page=Pcapy&file=pcapy-0.10.8.tar.gz"

How to install python3 version of package via pip on Ubuntu?

I have both python2.7 and python3.2 installed in Ubuntu 12.04.
The symbolic link python links to python2.7.
When I type:
sudo pip install package-name
It will default install python2 version of package-name.
Some package supports both python2 and python3.
How to install python3 version of package-name via pip?
Ubuntu 12.10+ and Fedora 13+ have a package called python3-pip which will install pip-3.2 (or pip-3.3, pip-3.4 or pip3 for newer versions) without needing this jumping through hoops.
I came across this and fixed this without needing the likes of wget or virtualenvs (assuming Ubuntu 12.04):
Install package python3-setuptools: run sudo aptitude install python3-setuptools, this will give you the command easy_install3.
Install pip using Python 3's setuptools: run sudo easy_install3 pip, this will give you the command pip-3.2 like kev's solution.
Install your PyPI packages: run sudo pip-3.2 install <package> (installing python packages into your base system requires root, of course).
…
Profit!
You may want to build a virtualenv of python3, then install packages of python3 after activating the virtualenv. So your system won't be messed up :)
This could be something like:
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
pip install package-name
Short Answer
sudo apt-get install python3-pip
sudo pip3 install MODULE_NAME
Source: Shashank Bharadwaj's comment
Long Answer
The short answer applies only on newer systems. On some versions of Ubuntu the command is pip-3.2:
sudo pip-3.2 install MODULE_NAME
If it doesn't work, this method should work for any Linux distro and supported version:
sudo apt-get install curl
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
sudo pip3 install MODULE_NAME
If you don't have curl, use wget. If you don't have sudo, switch to root. If pip3 symlink does not exists, check for something like pip-3.X
Much python packages require also the dev package, so install it too:
sudo apt-get install python3-dev
Sources:
python installing packages with pip
Pip latest install
Check also Tobu's answer if you want an even more upgraded version of Python.
I want to add that using a virtual environment is usually the preferred way to develop a python application, so #felixyan answer is probably the best in an ideal world. But if you really want to install that package globally, or if need to test / use it frequently without activating a virtual environment, I suppose installing it as a global package is the way to go.
Well, on ubuntu 13.10/14.04, things are a little different.
Install
$ sudo apt-get install python3-pip
Install packages
$ sudo pip3 install packagename
NOT pip-3.3 install
The easiest way to install latest pip2/pip3 and corresponding packages:
curl https://bootstrap.pypa.io/get-pip.py | python2
pip2 install package-name
curl https://bootstrap.pypa.io/get-pip.py | python3
pip3 install package-name
Note: please run these commands as root
I had the same problem while trying to install pylab, and I have found this link
So what I have done to install pylab within Python 3 is:
python3 -m pip install SomePackage
It has worked properly, and as you can see in the link you can do this for every Python version you have, so I guess this solves your problem.
Old question, but none of the answers satisfies me. One of my systems is running Ubuntu 12.04 LTS and for some reason there's no package python3-pip or python-pip for Python 3. So here is what I've done (all commands were executed as root):
Install setuptools for Python3 in case you haven't.
apt-get install python3-setuptools
or
aptitude install python3-setuptools
With Python 2.4+ you can invoke easy_install with specific Python version by using python -m easy_install. So pip for Python 3 could be installed by:
python3 -m easy_install pip
That's it, you got pip for Python 3. Now just invoke pip with the specific version of Python to install package for Python 3. For example, with Python 3.2 installed on my system, I used:
pip-3.2 install [package]
If you have pip installed in both pythons, and both are in your path, just use:
$ pip-2.7 install PACKAGENAME
$ pip-3.2 install PACKAGENAME
References:
http://www.pip-installer.org/docs/pip/en/0.8.3/news.html#id4
https://github.com/pypa/pip/issues/200
This is a duplicate of question #2812520
If your system has python2 as default, use below command to install packages to python3
$ python3 -m pip install <package-name>
Easy enough:
sudo aptitude install python3-pip
pip-3.2 install --user pkg
If you want Python 3.3, which isn't the default as of Ubuntu 12.10:
sudo aptitude install python3-pip python3.3
python3.3 -m pip.runner install --user pkg
You can alternatively just run pip3 install packagename instead of pip,
Firstly, you need to install pip for the Python 3 installation that you want. Then you run that pip to install packages for that Python version.
Since you have both pip and python 3 in /usr/bin, I assume they are both installed with a package manager of some sort. That package manager should also have a Python 3 pip. That's the one you should install.
Felix' recommendation of virtualenv is a good one. If you are only testing, or you are doing development, then you shouldn't install the package in the system python. Using virtualenv, or even building your own Pythons for development, is better in those cases.
But if you actually do want to install this package in the system python, installing pip for Python 3 is the way to go.
Although the question relates to Ubuntu, let me contribute by saying that I'm on Mac and my python command defaults to Python 2.7.5. I have Python 3 as well, accessible via python3, so knowing the pip package origin, I just downloaded it and issued sudo python3 setup.py install against it and, surely enough, only Python 3 has now this module inside its site packages. Hope this helps a wandering Mac-stranger.
Execute the pip binary directly.
First locate the version of PIP you want.
jon-mint python3.3 # whereis ip
ip: /bin/ip /sbin/ip /usr/share/man/man8/ip.8.gz /usr/share/man/man7/ip.7.gz
Then execute.
jon-mint python3.3 # pip3.3 install pexpect
Downloading/unpacking pexpect
Downloading pexpect-3.2.tar.gz (131kB): 131kB downloaded
Running setup.py (path:/tmp/pip_build_root/pexpect/setup.py) egg_info for package pexpect
Installing collected packages: pexpect
Running setup.py install for pexpect
Successfully installed pexpect
Cleaning up...
You should install ALL dependencies:
sudo apt-get install build-essential python3-dev python3-setuptools python3-numpy python3-scipy libatlas-dev libatlas3gf-base
Install pip3(if you have installed, please look step 3):
sudo apt-get install python3-pip
Iinstall scikit-learn by pip3
pip3 install -U scikit-learn
Open your terminal and entry python3 environment, type import sklearn to check it.
To install pip for python3 use should use pip3 instead of pip.
To install python in ubuntu 18.08 bionic
before installing a version of python, activate virtual environment so that it won't have any problem in a future versions of python.
virtualenv -p /usr/bin/python3 py3env
source py3env/bin/activate
then install the actual python version you want.
>> sudo apt-get install python3.7
To install the required pip package in ubuntu
>> sudo apt-get install python3-pip
You Can Simply type in terminal/console .
Commands
sudo apt update
sudo apt upgrade
sudo apt install python3-pip3
pip3 install package-name
Another way to install python3 is using wget. Below are the steps for installation.
wget http://www.python.org/ftp/python/3.3.5/Python-3.3.5.tar.xz
tar xJf ./Python-3.3.5.tar.xz
cd ./Python-3.3.5
./configure --prefix=/opt/python3.3
make && sudo make install
Also,one can create an alias for the same using
echo 'alias py="/opt/python3.3/bin/python3.3"' >> ~/.bashrc
Now open a new terminal and type py and press Enter.

Categories