飞行的猪哼哼

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

一:创建与使用虚拟环境:
1:mkvirtualenv -p python3 虚拟环境名称

ubuntu@python:~$ mkvirtualenv -p python3 py3_django
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/ubuntu/.virtualenvs/py3_django/bin/python3
Also creating executable in /home/ubuntu/.virtualenvs/py3_django/bin/python
Installing setuptools, pip, wheel...

done.
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/py3_django/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/py3_django/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/py3_django/bin/preactivate
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/py3_django/bin/postactivate
virtualenvwrapper.user_scripts creating /home/ubuntu/.virtualenvs/py3_django/bin/get_env_details

2:使用虚拟环境与退出虚拟环境:

(py3_django) ubuntu@python:~$ workon py3_django
(py3_django) ubuntu@python:~$ deactivate

3:删除虚拟环境:

ubuntu@python:~$ rmvirtualenv py3_django
Removing py3_django...

4:虚拟环境中安装django扩展包:

(python39_django) ubuntu@python:~$ pip install django==2.2.5 -i https://pypi.tuna.tsinghua.edu.cn/simple/
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple/
Collecting django==2.2.5
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/94/9f/a56f7893b1280e5019482260e246ab944d54a9a633a01ed04683d9ce5078/Django-2.2.5-py3-none-any.whl (7.5 MB)
     |████████████████████████████████| 7.5 MB 376 kB/s 
Collecting sqlparse
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/85/ee/6e821932f413a5c4b76be9c5936e313e4fc626b33f16e027866e1d60f588/sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 7.1 MB/s 
Collecting pytz
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4f/a4/879454d49688e2fad93e59d7d4efda580b783c745fd2ec2a3adf87b0808d/pytz-2020.1-py2.py3-none-any.whl (510 kB)
     |████████████████████████████████| 510 kB 214 kB/s 
Installing collected packages: sqlparse, pytz, django
Successfully installed django-2.2.5 pytz-2020.1 sqlparse-0.3.1

国内镜像源:

https://mirrors.aliyun.com/pypi/simple/
http://pypi.douban.com/simple/
http://pypi.mirrors.ustc.edu.cn/simple/

5:查看安装包:

(python39_django) ubuntu@python:~$ pip list
Package    Version
---------- -------
Django     2.2.5
pip        20.2.2
pytz       2020.1
setuptools 49.6.0
sqlparse   0.3.1
wheel      0.35.1

(python39_django) ubuntu@python:~$ pip freeze
Django==2.2.5
pytz==2020.1
sqlparse==0.3.1

安装包位置:~/.virtualenvs/虚拟环境名称/lib/python版本/site-packages

posted on 2020-08-25 10:30  飞行的猪哼哼  阅读(19)  评论(0)    收藏  举报