ubuntu18.0.4 python 开发环境
Posted bobolog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu18.0.4 python 开发环境相关的知识,希望对你有一定的参考价值。
pyenv
官方库:https://github.com/pyenv/pyenv.git
1)依赖环境
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils
2)下载
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
3)环境变量
# 追加下面内容到 ~/.bashrc(如果存在~/.bash_profile 则加到此文件)
export PATH="/home/whb/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
$ source ~/.bashrc(或者~/.bash_profile)
$ pyenv install --list
创建python的虚拟运行环境
[email protected]:~/mypython/projects/web$ pyenv virtualenv 3.6.6rc1 3.6.6v
Looking in links: /tmp/tmp5boe92t2
Requirement already satisfied: setuptools in /home/whb/.pyenv/versions/3.6.6rc1/envs/3.6.6v/lib/python3.6/site-packages (39.0.1)
Requirement already satisfied: pip in /home/whb/.pyenv/versions/3.6.6rc1/envs/3.6.6v/lib/python3.6/site-packages (10.0.1)
[email protected]:~/mypython/projects/web$ pyenv versions
system
* 3.6.6rc1 (set by /home/whb/mypython/projects/web/.python-version)
3.6.6rc1/envs/3.6.6v
3.6.6v
[email protected]~:mkdir -p mypython/projects/web
[email protected]~:cd mypython/projects/web
[email protected]:~/mypython/projects/web$ pyenv local 3.6.6v
(3.6.6v) [email protected]:~/mypython/projects/web$
(3.6.6v) [email protected]:~/mypython/projects/web$
Jupyter Notebook
搭建python2和python3共存的环境!
安装python和python-pip
--这个非常关键,注意ipython3和ipython, pip与pip3, python与python3
sudo apt-get install ipython3 python-cycler-doc dvipng ffmpeg inkscape python3-cairocffi python3-nose python3-pyqt4 python3-scipy python3-sip python3-matplotlib
$ pip install --upgrade pip //更新pip
$ pip3 install --upgrade pip
安装jupyter-notebook
$ pip install jupyter
$ pip3 install jupyter
配置可以同时使用python2和python3内核
(ipython
和ipython3
是上面安装的)
$ ipython kernel install--user
$ ipython3 kernel install --user
$ python3 -m ipykernel install--user
$ python2 -m ipykernel install--user
$ pip install -U ipykernel
$ jupyter-notebook
tkinter # If this fails your Python may not be configured for Tk解决方法
安装tk
>> sudo apt install python3-tk (Ubuntu)
>> yum install python3-tk (Centos)
安装tk开发类库:
>> sudo apt install tk-dev (Ubuntu)
>> yum install tk-devel (Centos)
以上是关于ubuntu18.0.4 python 开发环境的主要内容,如果未能解决你的问题,请参考以下文章