设为首页 收藏本站
查看: 634|回复: 0

[经验分享] python3.5环境准备

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-7-4 10:21:49 | 显示全部楼层 |阅读模式
一、安装pyenv

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#系统环境
# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

1、安装git
# yum -y install git
2、安装pyenv
# curl -L https://raw.githubusercontent.co ... bin/pyenv-installer | bash
或者参考:https://github.com/yyuu/pyenv-installer
3、配置环境变量
# vim /etc/profile.d/pyenv.sh   #定义的全局环境变量
export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
# . /etc/profile.d/pyenv.sh   #载入一下



二、安装python
1
2
3
4
5
6
7
8
9
10
11
12
13
1、安装编译工具
# yum -y install gcc make patch
2、安装依赖环境
# yum -y install gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel
3、升级pyenv(最新版本3.2也许没有在pyenv中)
# pyenv update
4、安装python3.5.2
# pyenv install 3.5.2   #这块可能安装比较慢,需要等待一会。
5、使用国内镜像安装
# mkdir ~/.pyenv/cache
# wget -c http://7d9qvq.com1.z0.glb.clouddn.com/Python-3.5.2.tgz
#  mv Python-3.5.2.tar.gz ~/.pyenv/cache/Python-3.5.2.tar.gz
# pyenv install 3.5.2



三、pyenv基本使用方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
1、local命令
# pyenv versions
* system (set by /root/.pyenv/version)
  3.5.2
# pyenv local 3.5.2    #切换到3.5.2
# python -V
Python 3.5.2    #已经切换成功
2、global命令
# pyenv global 3.5.2  #全局切换至3.5.2版本,不建议使用这条命令
3、virtualenv命令
# pyenv virtualenv 3.5.2 bjwf  #以3.5.2为模版创建python3.5.2虚拟环境bjwf
# ll ~/.pyenv/versions/
     3.5.2
     bjwf -> /root/.pyenv/versions/3.5.2/envs/bjwf
4、uninstall命令
# pyenv uninstall bjwf    #卸载某个版本(包括虚拟环境版本)
pyenv-virtualenv: remove /root/.pyenv/versions/3.5.2/envs/bjwf? y
# ll ~/.pyenv/versions/
drwxr-xr-x 7 root root 63 Jun 30 05:50 3.5.2
5、其他命令
# pyenv install –list   #列出可安装的版本
# pyenv rehash           #更新数据库
# pyenv versions         #查看当前已安装的所有版本
# pyenv global 3.5.2     #建议永远不要执行
# pyenv help             #查看帮助
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   install     Install a Python version using python-build
   uninstall   Uninstall a specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/yyuu/pyenv#readme



四、安装ipython,jupyter

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
1、配置国内镜像(pipe)
# mkdir ~/.pip
# vim ~/.pip/pip.conf
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyum.com
2、安装ipython
# pip install --upgrade pip   #我这块提升要先安装这个
# pip install ipyton
# ipython   #可以使用了
Python 3.5.2 (default, Jun 30 2016, 05:24:18)
Type "copyright", "credits" or "license" for more information.

IPython 4.2.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: print('hello world')
hello world
3、安装jupyter
# pip install jupyter
# # jupyter-notebook --ip=0.0.0.0 --port=8888 --no-browser    #前台运行
[I 06:24:43.608 NotebookApp] Serving notebooks from local directory: /root
[I 06:24:43.609 NotebookApp] 0 active kernels
[I 06:24:43.609 NotebookApp] The Jupyter Notebook is running at: http://0.0.0.0:8888/
[I 06:24:43.609 NotebookApp] Use Control-C to stop this server and shut down all kernels
[I 06:24:58.443 NotebookApp] 302 GET / (192.168.110.253) 2.11ms
[I 06:25:26.260 NotebookApp] Creating new notebook in

# nohup jupyter-notebook --ip=0.0.0.0 --port=8888 --no-browser &      #后台运行



wKiom1d30WyB1fYIAAC9Hf9FEhc538.jpg


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-239178-1-1.html 上篇帖子: python面向对象基础 下篇帖子: Python 3.5 安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表