pip3: command not found - python

I want to install TensorFlow following these instructions: https://web.archive.org/web/20170627102751/https://www.tensorflow.org/versions/r0.12/get_started/os_setup#pip_installation
But when I try this code on terminal, it returns an error.
$ sudo pip3 install --upgrade $TF_BINARY_URL
sudo: pip3: command not found
So I installed Homebrew and tried to uninstall and reinstall python3-pip, but didn't work.
MakotonoMacBook-ea:~ makotomiyazaki$ brew uninstall python3-pip
Error: No such keg: /usr/local/Cellar/python3-pip
MakotonoMacBook-ea:~ makotomiyazaki$ brew install python3-pip
Error: No available formula with the name "python3-pip"
==> Searching for a previously deleted formula...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
What should I do for getting pip3?
My OS is macOS High Sierra, and I have Python 3.6.2 already installed.
EDIT: I tried
python3 -m pip
and what's returned was this:
The directory '/Users/makotomiyazaki/Library/Caches/pip/http' or its
parent directory is not owned by the current user and the cache has
been disabled. Please check the permissions and owner of that
directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/makotomiyazaki/Library/Caches/pip' or its parent
directory is not owned by the current user and caching wheels has been
disabled. check the permissions and owner of that directory. If
executing pip with sudo, you may want sudo's -H flag.
You must give at least one requirement to install (see "pip help
install")
I also tried which pip3, but just I don't know if it worked...
MakotonoMacBook-ea:~ makotomiyazaki$ sudo which pip3 install --upgrade $TF_BINARY_URL
/usr/bin/install

You would need to install pip3.
On Linux, run first sudo apt update. Then the command would be: sudo apt install python3-pip
On Mac, using brew, first brew install python3
Then brew postinstall python3
Try calling pip3 -V to see if it worked.

I had this issue and I fixed it using the following steps
You need to completely uninstall python3-pip using:
sudo apt-get --purge autoremove python3-pip
Then resintall the package with:
sudo apt install python3-pip
To confirm that everything works, run:
pip3 -V
After this you can now use pip3 to manage any python package of your interest. Eg
pip3 install NumPy

Writing the whole path/directory eg. (for windows) C:\Programs\Python\Python36-32\Scripts\pip3.exe install mypackage. This worked well for me when I had trouble with pip.

its possible if you already have a python installed (pip) you could do a upgrade on mac by
brew upgrade python

Try this if other methods do not work:
brew install python3
brew link --overwrite python
brew postinstall python3

In my case, although python3-pip was already installed, it didn't recognize pip3. After reinstalling with
sudo yum reinstall python3-pip
it worked fine and recognized pip3 commands.

After yum install python3-pip, check the name of the installed binary. e.g.
ll /usr/bin/pip*
On my CentOS 7, it is named as pip-3 instead of pip3.

Related

I rm python3.9 can i get it back ,

I am new on linux and i tried to change the Symbolic link of python3 in /usr/bin/ ,
and i accidentally remove the python3.9 file !
But i know i didn't delete it completely Because there is still a lot of file called python3.9 .
After that 'apt' didn't work anymore and i got this error :
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
Now , I only have version 2.7 of python and i can't install another because apt don't work !!
This is the result of
:
So I hope someone can help me and I wish you a good afternoon
Edit: As you've lost apt command meaning you can't install or remove anything using apt command.
The possible way to fix this is by reinstalling respective apt-package of your architecture and then do the below python installation.
To install apt-package again download the .deb file from the “/etc/apt/sources.list” file. Lots of links for installation and upgrades for packages will be in this file.
Now find the downloading source using $cat /etc/apt/sources.list command.
Find /pool/main/a/apt/ directory under downloading source and then download the .deb file which matches your architecture and download it.
Thereafter install this using dpkg command like this
sudo dpkg -i PackageName.deb
Replace the PackageName with your file name (e.g- apt_1.6.13_arm64/apt_1.9.3_i386).
Restart the PC and then check the /usr/bin/ directory to ensure if it had properly installed .
If you get nothing there then run locate apt-get command to locate it. If you can't get it then there is no other way than reinstalling the OS itself.
If you have reinstalled apt then
use the following commands to freshly install Python.
Note that all the commands below will be for Python3 as you're concerned with version 3.9.
# To uninstall the Python only
sudo apt-get remove python3.9
# To uninstall the Python with all the packages also
sudo apt-get remove --auto-remove python3.9
# To remove all the dependencies and configuration files
sudo apt-get purge --auto-remove python3.9
Now to install the Python3. The following command will install the latest version of python3. which to this date is python3.9.
sudo apt-get install python3
You can use pip to manage the python packages also.
To install pip use the following command
sudo apt install python3-pip
Now to manage the python packages using pip
# To install package; replace PackageName with the name of package(like flask)
sudo pip install PackageName
# To uninstall package
sudo pip uninstall PackageName
If you get trouble with pip get list of all the commands pip uses with
sudo pip help
You can list all the Python version installed (on default location)
ls /usr/bin/python*
Hope this will help in resolving the problem.

How to install pip3 and paramiko in ubuntu 16.04 LTS?

I am trying to install python paramiko using below command:
pip3 install paramiko
then I got an error:
The program 'pip3' is currently not installed. You can install it by typing:
sudo apt install python3-pip
then tried to install pip using above command, the result is:
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version (8.1.1-2ubuntu0.4).
The following packages were automatically installed and are no longer required:
python3-babel python3-dateutil python3-decorator python3-funcsigs python3-gevent python3-greenlet python3-html2text python3-mock python3-ofxparse python3-passlib python3-pbr python3-psutil
python3-psycopg2 python3-pydot python3-pyinotify python3-pypdf2 python3-serial python3-stdnum python3-tz python3-usb python3-vatnumber python3-werkzeug python3-yaml
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 82 not upgraded.
Then I tried to install paramiko again but getting the same error, pip is not installed.
When I type pip3 --version the output is:
The program 'pip3' is currently not installed. You can install it by typing:
sudo apt install python3-pip
pip --version
Output is:
pip 10.0.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
How can I resolve this?
For pip on python 3 you have to enter the following command:
sudo apt install python3-pip
Hope this helps
I usually do:
sudo python3 -m pip install paramiko
or
python3 -m pip --version
instead of
pip3 install
I don't know why but python -m pip etc ... works better than just pip etc... in my case.
if you really don't have pip (but I thought it comes automatically with python now) you can also get it using:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
(from here)
it works on my computer, I don't know why sudo apt-get would not work but you can try this solution instead.

Pip command not found in bash - OSX [duplicate]

I downloaded pip and ran python setup.py install and everything worked just fine. The very next step in the tutorial is to run pip install <lib you want> but before it even tries to find anything online I get an error "bash: pip: command not found".
This is on Mac OS X. I'm assuming there's some kind of path setting that was not set correctly when I ran setup.py. How can I investigate further? What do I need to check to get a better idea of the exact cause of the problem?
EDIT: I also tried installing Python 2.7 for Mac in the hopes that the friendly install process would do any housekeeping like editing PATH and whatever else needs to happen for everything to work according to the tutorials, but this didn't work. After installing, running 'python' still ran Python 2.6 and PATH was not updated.
Why not just do sudo easy_install pip or if this is for python 2.6 sudo easy_install-2.6 pip?
This installs pip using the default python package installer system and saves you the hassle of manual set-up all at the same time.
This will allow you to then run the pip command for python package installation as it will be installed with the system python. I also recommend once you have pip using the virtualenv package and pattern. :)
2020 Update:
For current Debian/Ubuntu, use
apt-get install python3-pip
to install pip3.
Old 2013 answer (easy_install is now deprecated):
Use setuptools to install pip: sudo easy_install pip
(I know the above part of my answer is redundant with klobucar's, but I can't add comments yet), so here's an answer with a solution to sudo: easy_install: command not found on Debian/Ubuntu: sudo apt-get install python-setuptools
Also, for python3, use easy_install3 and python3-setuptools.
For Python 3, use apt-get install python3-pip.
First of all: try pip3 instead of pip. Example:
pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
pip3 should be installed automatically together with Python3.x. The documentation hasn't been updated, so simply replace pip by pip3 in the instructions, when installing Flask for example.
Now, if this doesn't work, you might have to install pip separately.
Update: A more reliable modern way to access the right pip install for the right python install is to use the syntax python -m pip.
Original Answer
pip would install itself into the bin of your python installation location. It also should create a symlink to some more common location like /usr/local/bin/pip
You can either edit your ~/.profile and update your PATH to include /Library/Frameworks/Python.framework/Versions/2.6/bin, or you could create a symlink to it in a place that you know is in your path.
If you do: echo $PATH, you should see the paths currently being searched. If /usr/local/bin is in your PATH, you can do:
ln -s /Library/Frameworks/Python.framework/Versions/2.6/bin/pip /usr/local/bin
I would opt for adding the python bin to your $PATH variable.
I encountered this problem having downloaded python 3.x.x and trying to install awscli - pip: command not found.
Whilst following the instructions for downloading the AWS client, I changed
pip install awscli
to
pip3 install awscli
which ran the correct version.
I've made an alias on my machine to run python3 whilst typing python, which would normally run the system version 2.7. I'm not sure this is a good idea now. I think I'll just type in the commands as they intended them to be.
Check out How to Install Pip article for more information.
As of 2019,
Download get-pip.py provided by https://pip.pypa.io using the following command:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Run get-pip.py using the following command:
sudo python get-pip.py
After you done installing, run this command to check if pip is installed.
pip --version
Remove get-pip.py file after installing pip.
rm get-pip.py
Install Python latest version as given here
It has many download links like numpy and scipy
Then go to terminal and enter following command:-
sudo easy_install pip
For Python install packages check this
Requirements for Installing Packages
This section describes the steps to follow before installing other Python packages.
Install pip, setuptools, and wheel If you have Python 2 >=2.7.9 or
Python 3 >=3.4 installed from python.org, you will already have pip
and setuptools, but will need to upgrade to the latest version:
On Linux or OS X:
pip install -U pip setuptools On Windows:
python -m pip install -U pip setuptools If you’re using a Python
install on Linux that’s managed by the system package manager (e.g
“yum”, “apt-get” etc…), and you want to use the system package manager
to install or upgrade pip, then see Installing pip/setuptools/wheel
with Linux Package Managers
Otherwise:
Securely Download get-pip.py 1
Run python get-pip.py. 2 This will install or upgrade pip.
Additionally, it will install setuptools and wheel if they’re not
installed already.
I spent ages going through all the answers on this page but found the one that worked for me in the comments of the OP question by s-walsh
The answer is to use pip3:
$ pip3 install <name-of-install>
Installing using apt-get installs a system wide pip, not just a local one for your user. Try this command to get pip running on your system ...
$ sudo apt-get install python-pip python-dev build-essential
Then pip will be installed without any issues and you will be able to use "sudo pip...".
Most of the methods to install PIP are deprecated. Here is the latest (2019) solution. Please download get-pip script
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Run the script
sudo python get-pip.py
Latest update 2021.
In Ubuntu 20 64bit works perfectly
Installation of python3
sudo apt install python3
Pip Installation
sudo apt install python3-pip
Add following alias in $HOME/.bash_aliases in some cases file may be hidden.
alias pip="/usr/bin/python3 -m pip "
Refresh current terminal session.
. ~/.profile
check pip usage: pip
Install a package: pip install {{package_name}}
extra info
to get Home path
echo $HOME
you will get your home path.
To solve:
Add this line to ~/.bash_profile:
export PATH="/usr/local/bin:$PATH"
In a terminal window, run
source ~/.bash_profile
It might be the root permission. I tried exit root login, and use
sudo su -l root
pip <command>
install Homebrew, open Terminal or your favorite OSX terminal emulator and run
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line at the bottom of your ~/.profile file
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
Now, we can install Python 2.7:
$ brew install python
Get pip repository:
$ git clone https://github.com/pypa/pip
install pip:
$sudo easy_install pip
python install it by default but if not install you can install it manual use following cmd (for linux only )
for python3 :
sudo apt install python3-pip
for python2
sudo apt install python-pip
hope its help.
If you are running Python 3.5, run the following terminal command:
sudo pip3 install -U nltk
Any other pip commands in terminal would be similar:
pip3 install --upgrade pip
sudo pip3 install -U numpy ::
It solved my problem by using
sudo easy_install pip
Solved this by upgrading python 3 brew upgrade python:
Now i can just do:
pip3 install <package>
==> python
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have
Based on this stackoverflow answer and some of the answers on this thread, I have created an alias in the rc file:
alias pip="python3 -m pip"
There seem to be many different answers to this question but this seems to be the best-practice approach.
Avoiding sudo:
python <(curl https://bootstrap.pypa.io/get-pip.py) --user
echo 'export "PATH=$HOME/Library/Python/2.7/bin:$PATH"' >> ~/.bash_profile
From:
http://www.pip-command-not-found.com
CentOS 7 users can just use:
yum install python-pip
Also recommend using virtualenv if you're using pip. It can be added in the same way:
yum install python-virtualenv
assuming you have internet see:
https://pip.pypa.io/en/stable/installing/
basically run:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
and
python get-pip.py
Try using this. Instead of zmq, we can use any package instead of zmq.
sudo apt-get install python3-pip
sudo apt-get update
python3 -m pip install zmq
I was was not able to install this zmq package in my docker image because of the same issue i was getting. So tried this as another way to install and it worked fine for me.
To overcome the issue bash: pip: command not found in Mac
Found two versions on Mac 1 is 2.7 and the other is 3.7
when I say sudo easy_install pip, pip got installed under 2.7
when I say sudo easy_install-3.7 pip, pip got installed under 3.7
But, whenever I would require to do pip install , I wanted to install the package under python3.7, so I have set an alias (alias pip=pip3) in .bash_profile.
so now, whenever I do pip install <package_name>, it gets installed under python3.7
(Context: My OS is Amazon linux using AWS. It seems similar to RedHat but it's stripped down a bit, it seems.)
Exit the shell, then open a new shell. The pip command now works.
That's what solved the problem at this location.
You might want to know as well: The pip commands to install software then needed to be written like this example (jupyter for example) to work correctly on my system:
pip install jupyter --user
Specifically, note the lack of sudo, and the presence of --user
Would be real nice if pip docs had said anything about all this, but that would take typing in more characters I guess.
Not sure why this wasnt mentioned before, but the only thing that worked for me (on my NVIDIA Xavier) was:
sudo apt-get install python3-pip
(or sudo apt-get install python-pip for python 2)
apt -y -qq install python3 python3-pip
ln -s /usr/bin/python3 /usr/bin/python
ln -s /usr/bin/pip3 /usr/bin/pip
What I did to overcome this was sudo apt install python-pip.
It turned out my virtual machine did not have pip installed yet. It's conceivable that other people could have this scenario too.
The updated command for installing pip3 is :
sudo apt-get install python3-pip
The problem seems that your python version and the library yoıu want to install is not matching versionally. Ex: If Django is Django3 and your python version is 2.7, you may get this error.
"After installing is running 'python' still ran Python 2.6 and PATH was not updated."
1- Install latest version of Python
2- Change your PATH manually as python38 and compare them.
3- Try to reinstall.
I solved this problem as replacing PATH manually with the latest version of Python.
As for Windows: ;C:\python38\Scripts

How can I install Python's pip3 on my Mac?

I'm trying to install pip3, but I'm not having any luck. Also, I tried sudo install and it did not work. How could I install pip3 on my Mac?
sudo easy_install pip3
Password:
Searching for pip3
Reading https://pypi.python.org/simple/pip3/
Couldn't find index page for 'pip3' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
No local packages or download links found for pip3
error: Could not find suitable distribution for Requirement.parse('pip3')
UPDATED - Homebrew version after 1.5
According to the official Homebrew page:
On 1st March 2018 the python formula will be upgraded to Python 3.x and a python#2 formula will be added for installing Python 2.7 (although this will be keg-only so neither python nor python2 will be added to the PATH by default without a manual brew link --force). We will maintain python2, python3 and python#3 aliases.
So to install Python 3, run the following command:
brew install python3
Then, the pip or pip3 is installed automatically, and you can install any package by pip install <package>.
The older version of Homebrew
Not only brew install python3 but also brew postinstall python3
So you must run:
brew install python3
brew postinstall python3
Note that you should check the console, as it might get you errors and in that case, the pip3 is not installed.
You could use Homebrew.
Then just run:
brew install python3
I solved the same problem with these commands:
curl -O https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
For me brew postinstall python3 didn't work. I found this solution on the GitHub Homebrew issues page:
$ brew rm python
$ rm -rf /usr/local/opt/python
$ brew cleanup
$ brew install python3
Python 3 was working successfully, but without pip3. I tried advice from Stack Overflow, Quora and others (numerous installs and uninstalls).
Python 3 was always fine, but without pip3. Finally I downloaded Python3 from:
https://www.python.org/downloads/
By simple mouse clicks and everything (Python 3 + pip3), it is working fine now.
To install or upgrade pip, download get-pip.py from the official site. Then run the following command:
sudo python get-pip.py
and it will install pip for your python version which runs the script.
Similar to Oksana but add python3
$ brew rm python
$ brew rm python3
$ rm -rf /usr/local/opt/python
$ rm -rf /usr/local/opt/python3
$ brew prune
$ brew install python3
$ brew postinstall python3
Seem now work for pip3 under mac os x 10.13.3 Xcode 9.2
I ran the below where <user>:<group> matched the other <user>:<group> for other files in the /usr/local/lib/python3.7/site-packages/ directory:
sudo chown -R <user>:<group> /usr/local/lib/python3.7/site-packages/pip*
brew postinstall python3
I also encountered the same problem but brew install python3 does not work properly to install pip3.
brre will throw the warning The post-install step did not complete successfully.
It has to do with homebrew does not have permission to /usr/local
Create the directory if not exist
sudo mkdir lib
sudo mkdir Frameworks
Give the permissions inside /usr/local to homebrew so it can access them:
sudo chown -R $(whoami) $(brew --prefix)/*
Now ostinstall python3
brew postinstall python3
This will give you a successful installation
After upgrading to macOS v10.15 (Catalina), and upgrading all my vEnv modules, pip3 stopped working (gave error: "TypeError: 'module' object is not callable").
I found question 58386953 which led to here and solution.
Exit from the vEnv (I started a fresh shell)
sudo python3 -m pip uninstall pip (this is necessary, but it did not fix problem, because it removed the base Python pip, but it didn't touch my vEnv pip)
sudo easy_install pip (reinstalling pip in base Python, not in vEnv)
cd to your vEnv/bin and type "source activate" to get into vEnv
rm pip pip3 pip3.6 (it seems to be the only way to get rid of the bogus pip's in vEnv)
Now pip is gone from vEnv, and we can use the one in the base Python (I wasn't able to successfully install pip into vEnv after deleting)
Installing Pip3
Follow this link to download pip3 on your computer
Follow the instructions on the page and then after successfully downloading Pip3, run python3 get-pip.py in your terminal
This will install pip3 into your laptop and then you can check the installation of pip3 by running which pip3 in your terminal.
Now simply do pip3 install <package>
If you're using Python 3, just execute python3 get-pip.py . It is just a simple command.

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