Dealing with multiple Python versions and PIP?

后端 未结 23 2778
走了就别回头了
走了就别回头了 2020-11-21 06:58

Is there any way to make pip play well with multiple versions of Python? For example, I want to use pip to explicitly install things to either my s

23条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-21 07:39

    If you have both python3.6 and python3.7 installed and want to use pip with python3.7 by default, here's what you should do:

    First make sure you have pip installed for python3.7

    python3.7 -m pip install -U pip
    

    Now pip3.7 must be available, so we edit .bashrc

    nano ~/.bashrc
    

    adding the following line to it

    alias pip=pip3.7
    

    In order for the changes to take effect type in the shell:

    source ~/.bashrc
    

    Now if you type:

    pip --version
    

    you should get:

    pip 20.1.1 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)

    which means, if you use, for example:

    pip install 
    

    it would install the for python3.7

提交回复
热议问题