Best way to Install Pip packages(Ubuntu/Linux) [closed] - python

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 months ago.
Improve this question
I was wondering since there are so many optinos to install a python package which one is be best and most convenient. should I install packages with sudo and pip3 commands,
E.g
sudo pip3 install <package>
only using pip3
E.g
pip3 install <package>
or using apt
sudo apt install <python-package>
I was wondering which is the go-to and will be most convenient in the future. Mostly wondering what is the difference between Sudo pip3 and pip3 what difference does it make and which one I should use.

Don't use sudo with pip. There is a chance you'll overwrite system-installed packages, and mess up your OS.
sudo apt install <python-package> is pretty safe, but may result in outdated packages, and will definitely not include all packages you may want to install.
pip3 install <package> will install packages for just the current user (thus, not system-wide; if you're the only user, you're fine), and is what I would recommend.
Going further, virtual environment or use of Conda (an "extended" virtual environment manager) are potentially even safer, at the cost of a little more work to set up, and a bit more disk space (usually, the latter is insignificant).
You will have to read up on the use of virtual environment or Conda. That topic is too long for a standard answer here.

I would suggest as first step reading package documentation, as it often contains information regarding how to install it. Few examples regarding popular packages
click suggests pip install click
jinja2 suggests pip install Jinja2
requests suggests python -m pip install requests
Before that check to what version pertains python in your machine (by checking output of python --version), if it is Python 2 and you want to install packages to Python 3, then you need to use pip3 and python3 rather than pip and python, if it is Python 3 you might use command as they are.

Related

Ansible is not installing via PIP [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I was following the tutorial on Ansible docs but was unable to finish it:
$ python -m pip install --user ansible
Returns an error:
/usr/bin/python: No module named pip
While another guide installed it by using python-pip3 and then after running pip3 install --user ansible it was ready to go.
It finishes installation successfully, yet ansible is still not available:
-bash: /usr/bin/ansible: No such file or directory
I have never worked with Python or PIP in the past and I don't understand what could go wrong in the process to start debugging.
You should check your python version in the terminal with
$ which python
command and then this returns a path that contains python(probably this will return a path because almost all of Linux distro contains python). After that result, you could type
$ curl https://bootstrap.pypa.io/get-pip.py
in the terminal, and then type
$ python get-pip.py
pip will be installed after these commands.
I have not found a solution to this but instead I went with the CentOS Epel repository also described in the Ansible docs and it works this way.
sudo yum install epel-release
sudo yum install ansible
Edit: Ok, so all I had to do is to add the following to .bashrc file.
export PATH="$HOME/.local/bin:$PATH"
Fixed.

Use Python 3 in OpenWRT Build System [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Trying to create OpenWRT build system for Omega linux on chip device according to manual on my Ubuntu 20. Got error below while run make menuconfig
...
Checking 'python'... failed.
...
Build dependency: Please install Python 2.x
My system has Python 3 while manual asks to install Python 2.
How to solve this problem?
Since Python3 is not backward compatible you need to provide Python2 for installation. Follow this instructions to create an isolated Python2 environment in your system:
Install Python2 (add repository if needed):
sudo apt install python2
Install pip (package manager):
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
sudo python2 get-pip.py
Install virtualenv:
sudo apt install virtualenv
Create virtual environment for Python2 in your favorite directory (change myenv to your favorite name):
virtualenv --python=python2 myenv
Activation:
source myenv/bin/activate
Deactivation:
deactivate
You can also install required python packages (if needed) by using pip in your activated environment.

Can't download Django [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 6 years ago.
Improve this question
So I have Python on my new Macbook Air and now I'm trying to download Django and having no luck. I've tried "wget" and the link from the Django site, then I downloaded it and tried "python setup.py install". In both cases I get invalid syntax. I have Python 2.712. I'd really appreciate any help!!
Thanks, Tom
The easiest way to install django is probably to use pip. You should already have it installed since you're running a Python 2.7 version greater than 2.7.9.
The latest official docs read:
Installing an official release with pip
This is the recommended way to install Django.
Install pip. The easiest is to use the standalone pip installer. If your distribution already has pip installed, you might need to update it if it’s outdated. If it’s outdated, you’ll know because installation won’t work.
Take a look at virtualenv and virtualenvwrapper. These tools provide isolated Python environments, which are more practical than installing packages systemwide. They also allow installing packages without administrator privileges. The contributing tutorial walks through how to create a virtualenv on Python 3.
After you’ve created and activated a virtual environment, enter the command pip install Django at the shell prompt.
The main reason for install django is that the django version is not match your python. From the notice of the Django official website and your python version, i think FOR python 2.7 the best django version is 1.8.X.
Here is the download link:
https://www.djangoproject.com/download/1.8.17/tarball/
You can download this version, and try the installation again.
Please see the official docs as this link.
https://docs.djangoproject.com/en/1.8/topics/install/#installing-official-release
With MacOSX, you have to download pip installer, then you can download very easily Django from pip.
I put two possibilities, depending to Python2 or Python3 :
# if pip not installed
$ sudo easy_install pip
# show current pip version
$ pip --version
# upgrade pip
$ sudo pip install --upgrade pip
Then you have to download Django :
# Django version for Python2
$ pip install Django
or
# Django version for Python3
$ pip3 install Django
You can check the Django version :
python -m django --version

apt-get install unable to locate package on ubuntu 12.04 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I'm trying to install matplotlib on my ubuntu 12.04 system with python3. I've read that this package should be available in the package manager, but when I type
sudo apt-get install python3-matplotlib
I get
E: Unable to locate package python3-matplotlib
I've tried
sudo apt-get update
sudo apt-get upgrade
and I still get the error. I know this is a simple problem, but I can't figure it out.
Because the package does not exist, see:
http://packages.ubuntu.com/search?keywords=matplotlib&searchon=names&suite=precise&section=all
If you need matplotlib + python3 on 12.04 you will probably have to install it from source.
As tcaswell pointed out, it doesn't seem to be included in the official Ubuntu repos. You could try to find an external repo for it, but I think you'll be better off installing the version from PyPI.
pip install matplotlib
Most people prefer to install python dependencies using a tool like pip, which defaults to the PyPI repo for downloads.
You could also install from source but then upgrading can become tricky. On the other hand for most packages PyPI will receive updates well before they work their way down to a distro's repo.

Clean Re-Install of Python on OSX & Linux [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
My various Python upgrades, both Ubuntu and OSX, are so gnarled that I can't escape with virtualenv 'cause virtualenv itself doesn't work. I want to lift off and nuke the site from orbit, it's the only way to be sure.
What is the easiest way to uninstall any upgrades, returning the machines to installed defaults, and proceed forward with 2.7 in a virtual environment?
EDIT: Please to note, I installed 2.7 from source on both systems.
EDIT: I've voted to close -- out of place here, and I've figured out enough to get me through the next thing. Thx to all for reading.
To remove python installed from source:
First try
sudo make uninstall
Last time I checked, Python's source Makefile does not come with an uninstall target, but just in case things have changed, it does not hurt to try this.
Assuming that does not work, install checkinstall:
sudo apt-get install checkinstall # install the checkinstall package
cd /path/to/python/source/
sudo checkinstall -D --fstrans=no make install # make the deb package
This will create a .deb file for all the files installed by make install.
checkinstall will ask a few questions; the default answers should be fine.
You should end up with a deb package called something like Python-2.7.deb
Now you can uninstall python with
sudo dpkg -r Python-2.7 # Change Python2.7 to the name of the deb package.
This method has been known to work, at least for an earlier version of Python.

Categories