码迷,mamicode.com
首页 > 编程语言 > 详细

python

时间:2018-08-01 15:21:58      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:images   cer   text   you   ext   line   may   1.5   form   

root用户下

root@ubuntu:/home/huangyong# pip install virtualenv

Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/dist-packages

Cleaning up...

root@ubuntu:/home/huangyong# virtualenv python_env

New python executable in /home/huangyong/python_env/bin/python2.7

Also creating executable in /home/huangyong/python_env/bin/python

Installing setuptools, pip, wheel...done.

root@ubuntu:/home/huangyong# source ./python_env/bin/activate  (切换到了我们的env环境下)

python -V 查看版本

pip list 将会列出所有安装在虚拟环境中的包

(python_env) root@ubuntu:/home/huangyong# pip install django

Collecting django

/home/huangyong/python_env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.

  SNIMissingWarning

/home/huangyong/python_env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.

  InsecurePlatformWarning

  Using cached Django-1.10.5-py2.py3-none-any.whl

Installing collected packages: django

Successfully installed django-1.10.5

(python_env) root@ubuntu:/home/huangyong#

(python_env) root@ubuntu:/home/huangyong# django-admin.py startproject mySite

(python_env) root@ubuntu:/home/huangyong# cd mySite

(python_env) root@ubuntu:/home/huangyong/mySite# python manage.py runserver 

Performing system checks...

 

System check identified no issues (0 silenced).

 

You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.

Run 'python manage.py migrate' to apply them.

 

January 11, 2017 - 07:39:38

Django version 1.10.5, using settings 'mySite.settings'

Starting development server at http://127.0.0.1:8000/

Quit the server with CONTROL-C.

[11/Jan/2017 07:40:09] "GET / HTTP/1.1" 200 1767

Not Found: /favicon.ico

[11/Jan/2017 07:40:09] "GET /favicon.ico HTTP/1.1" 404 1936

看到下图成功了!

技术分享图片技术分享图片

2. 卸载Django

    sudo pip uninstall Django

sudo apt-get autoremove

Pycharm配置虚拟环境

 file--->settings--->Project:你的克隆包--->Project Interpreter(找到设置)--->AddLocal--->(找到你的    虚拟环境的位置)

技术分享图片

virtualenv创建隔离的Python环境

简要步骤

1、安装pip

$ sudo apt-get install python-pip

2、安装virtualenv

$ sudo pip install virtualenv

3、创建一个隔离环境

$ virtualenv test

4、激活隔离环境

$ source test/bin/activate

5、我们就可以看到在命令行的前面已经加上了(test),这个时候我们看看python所指向的路径:

$ which python

6、安装django1.5.1,不要加sudo

$ pip install Django==1.5.1

7、运行python,键入import django,回车,没报错就是安装好了。

补充

若要退出虚拟环境

$ deactivate

若要卸载pip

$ sudo apt-get remove python-pip

若要卸载virtualenv

$ sudo pip uninstall virtualenv


python

标签:images   cer   text   you   ext   line   may   1.5   form   

原文地址:http://blog.51cto.com/xiaok007/2153123

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!