How can I control which Python distribution to pip install a package to when I have Python 2, Python 3, and Anaconda on my computer?

前端 未结 4 1342
囚心锁ツ
囚心锁ツ 2021-02-08 05:15

I have the following Python distributions installed on my Windows computer:

  • Python 2.7 (IDLE)
  • Python 3.4 (IDLE)
  • Anaconda (Python 3.4)
4条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-08 05:25

    I'm not sure why you need so many different Pythons, but for Anaconda, you should use conda.

    conda install pytz
    

    will install pytz into your Anaconda Python.

    If all you are aiming to do is to have both Python 2 and Python 3 you can do this with conda.

    conda create -n py27 python=2.7 anaconda
    

    will create a conda environment (similar to a virtualenv but more powerful) with the Python 2.7 version of Anaconda. You can then activate this with

    activate py27
    

    See http://continuum.io/blog/anaconda-python-3.

    You can also use pip with Anaconda, but using conda is recommended unless the package you need is not available through conda.

提交回复
热议问题