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

前端 未结 17 1749
粉色の甜心
粉色の甜心 2020-11-22 11:03

I have both python2.7 and python3.2 installed in Ubuntu 12.04.
The symbolic link python links to python2.7

相关标签:
17条回答
  • 2020-11-22 11:37
    1. You should install ALL dependencies:

      sudo apt-get install build-essential python3-dev python3-setuptools python3-numpy python3-scipy libatlas-dev libatlas3gf-base

    2. Install pip3(if you have installed, please look step 3):

      sudo apt-get install python3-pip

    3. Iinstall scikit-learn by pip3

      pip3 install -U scikit-learn

    4. Open your terminal and entry python3 environment, type import sklearn to check it.

    Gook Luck!

    0 讨论(0)
  • 2020-11-22 11:39

    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
    
    0 讨论(0)
  • 2020-11-22 11:39

    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]
      
    0 讨论(0)
  • 2020-11-22 11:39

    To install pip for python3 use should use pip3 instead of pip. To install python in ubuntu 18.08 bionic

    sudo apt-get install python3.7

    To install the required pip package in ubuntu

    sudo apt-get install python3-pip

    0 讨论(0)
  • 2020-11-22 11:40

    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.

    0 讨论(0)
提交回复
热议问题