Ubuntu16.04下搭建python开发环境

准备工作:安装虚拟机,并下载安装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 [虚拟环境名称]

  • 9
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值