I have Python3 and Python2 and also pip and pip3 for various python version package installation.

I want install a ZMQ library in Python 2 and 3, I did it in python2 as well with the following line:

sudo pip install zmq

But when I using pip3 for ZMQ installation on Python3 I have a problem:

$ pip3 install zmq
Collecting zmq
Collecting pyzmq (from zmq)
  Using cached https://files.pythonhosted.org/packages/94/e8/6b39ec62b4f7821eeefd69e0c1ddfd56744cd6613f8216fc972cfc8d7765/pyzmq-17.1.0-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: pyzmq, zmq
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/zmq'
Consider using the `--user` option or check the permissions.

Then when I used sudo before pip3:

$ sudo pip3 install zmq
sudo: pip3: command not found


$ pip --version
pip 18.0 from /home/benyamin/.local/lib/python3.6/site-packages/pip (python 3.6)

$ pip3 --version
pip 18.0 from /home/benyamin/.local/lib/python3.6/site-packages/pip (python 3.6)

$ which pip

$ which pip3

$ sudo which pip

$ sudo which pip3
$ # no output

It seems that my pip is for Python3.6!

Any help would be greatly appreciated.

  • pip3 is installed in user scope. You have to install pip3 globally. or you have to install zmq in user scope. Try pip3 install --user zmq
    – dedunumax
    Aug 7 '18 at 6:42
  • @dedunumax how can I install pip3 globally? Aug 7 '18 at 6:45
  • @dedunumax I did it : pip3 install --<my-user> zmq but I confronted with permission denided again Aug 7 '18 at 6:47
  • 1
    Dont add your user name just type user
    – dedunumax
    Aug 7 '18 at 6:51
  • Did you try it with just user?
    – dedunumax
    Aug 7 '18 at 7:12

First remove your local pip:

/home/benyamin/.local/bin/pip3 uninstall pip

Install it using apt:

sudo apt install python3-pip

or for "python2":

sudo apt install python-pip

then run:

sudo pip3 install zmq

you can also update pip using:

sudo pip3 install pip --upgrade

Alternative solution is to creat an alias:

alias pip3='sudo /home/benyamin/.local/bin/pip3'
  • With this instruction can I have both pip for Python2 and pip3 for Python3 simultaneously? Aug 7 '18 at 8:06
  • 1
    Yep, just install both of them...
    – Ravexina
    Aug 7 '18 at 8:07
  • when I did /home/benyamin/.local/lib/python3.6/site-packages/pip uninstall pip confront with bash: /home/benyamin/.local/lib/python3.6/site-packages/pip: Is a directory Aug 7 '18 at 10:22
  • @BenyaminJafari what about this one: /home/benyamin/.local/bin/pip3 uninstall pip
    – Ravexina
    Aug 7 '18 at 10:28
  • bash: /home/benyamin/.local/bin/pip3: No such file or directory Aug 7 '18 at 10:30

Open the terminal and type:

sudo apt install python3-pip   
sudo -H pip3 install --upgrade pip  

Create a symbolic link at /home/benyamin/.local/bin/pip3 which references to file /usr/local/bin/pip3.

cd /home/benyamin/.local/bin/
rm pip3
sudo ln -s /usr/local/bin/pip3 /home/benyamin/.local/bin/pip3

Check location of the pip3 executable file and pip3 version.

which pip3  
pip3 --version  

Install zmq.

python3 -m pip install --user zmq
  • 1
    Thanks for the answer, I update my question in NOTE section, please read that ... Aug 7 '18 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.