美文网首页
ubuntu use python in virtualenv

ubuntu use python in virtualenv

作者: mugtmag | 来源:发表于2016-12-05 18:58 被阅读12次

    when you have installed python3.5 or python2.7, then copy codes following to use python3.5 or python2.7 in virtualenv.

    1. install pip
    $ sudo apt-get install python-pip
    
    1. use pip to install virtualenv
    $ pip install virtualenv
    
    1. make a directory noly for virtualenv environment
     $ mkdir virtualenvs
    
    1. Install python3.5 virtualenv, "--no-site-packages" means to make site-packages for python3.5 in virtualenv are separated from site-packages out of the virtualenv.
    $ cd virtualenvs/
    $ virtualenv --no-site-packages --distribute -p /usr/bin/python3.5 py3.5
    
    1. activate py3.5
    $ source py3.5/bin/activate
    
    1. check the python version at present.
    $ which python
    
    1. you can also deactivate py3.5
    $ deactivate
    
    1. you may have python2.7 virtualenv as well. Use code like py3.5.
    $ virtualenv --no-site-packages --distribute -p /usr/bin/python2.7 py2.7
    

    If you have two python version (python2 and python3),you can use sudo apt install virtualenv
    Also, you can use source py3.5/bin/activate and deactivate to change python versions.

    相关文章

      网友评论

          本文标题:ubuntu use python in virtualenv

          本文链接:https://www.haomeiwen.com/subject/rvqlmttx.html