准备工作:安装虚拟机,并下载安装Ubuntu16.04系统
1.ubuntu默认root用户没有激活,激活root用户,就要为root用户创建密码
$sudo passwd root
2、修改主机名
$vi /etc/hostname
3、安装ssh服务
$sudo apt-get install openssh-server
//安装sshd服务
$ sudo apt-get install openssh-server
//开启服务
$ /etc/init.d/ssh start
//关闭服务
$ /etc/init.d/ssh stop
//重启服务
$ /etc/init.d/ssh restart
4、安装Xshell软件,链接虚拟机ubuntu
5、浏览器访问虚拟机里的web server
首先你的虚拟机应该与你的win系统网络访问正常启动web Server时确认其启动在对外能够访问的IP( 0.0.0.0 ) 和端口上
6、安装python2.7
$ sudo apt-get install python2.7
$ which python2.7
$ which python3
$ python --version
Arvin@Arvin:~/tools/pip$ which python2.7
/usr/bin/python2.7
Arvin@Arvin:~/tools/pip$ python2.7
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
创建软连接:
$ ln -s 源文件 目标文件
$ sudo ln -s /usr/bin/python2.7 /usr/bin/python
lrwxrwxrwx 1 root root 18 Mar 28 23:23 /usr/bin/python -> /usr/bin/python2.7
lrwxrwxrwx 1 root root 18 Mar 28 23:22 /usr/bin/python2 -> /usr/bin/python2.7
-rwxr-xr-x 1 root root 3546104 Nov 19 01:35 /usr/bin/python2.7
lrwxrwxrwx 1 root root 9 Mar 28 03:22 /usr/bin/python3 -> python3.5
-rwxr-xr-x 2 root root 4460336 Nov 17 11:23 /usr/bin/python3.5
7、安装setuptools
$ sudo apt-get install python-setuptools
8、安装pip
Arvin@Arvin:~/tools/pip$ wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
--2017-03-28 22:44:39-- https://bootstrap.pypa.io/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.72.175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.72.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1595408 (1.5M) [text/x-python]
Saving to: ‘get-pip.py’
get-pip.py 100%[===================>] 1.52M 933KB/s in 1.7s
2017-03-28 22:44:41 (933 KB/s) - ‘get-pip.py’ saved [1595408/1595408]
执行安装pip命令
Arvin@Arvin:~/tools/pip$ sudo python get-pip.py
警告解决办法
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
新建pip源配置文件
$ mkdir ~/.pip
$ vim ~/.pip/pip.conf
添加内容
[list]
format=columns
pip源配置文件可以放置的位置
Linux/Unix:
/etc/pip.conf
~/.pip/pip.conf
~/.config/pip/pip.conf
9、安装virtualenv和virtualenvwrapper
sudo apt-get update
$sudo apt-get install python-virtualenv
$sudo easy_install virtualenvwrapper
上述工具装好后找不到mkvirtualenv命令,需要执行以下环境变量设置
1.创建目录用来存放虚拟环境
mkdir $HOME/.virtualenvs
2.在~/.bashrc中添加行:
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
3.运行:
source ~/.bashrc
3.创建python虚拟环境
mkvirtualenv [虚拟环境名称]
4.切换虚拟环境
workon [虚拟环境名称]