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的虚拟运行环境
whb@ubuntu1804:~/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)
  
whb@ubuntu1804:~/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
whb@ubuntu1804~:mkdir -p mypython/projects/web
whb@ubuntu1804~:cd mypython/projects/web
whb@ubuntu1804:~/mypython/projects/web$ pyenv local 3.6.6v
(3.6.6v) whb@ubuntu1804:~/mypython/projects/web$
(3.6.6v) whb@ubuntu1804:~/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内核

(ipythonipython3是上面安装的)

$ ipython kernel install--user
$ ipython3 kernel install --user
$ python3 -m ipykernel install--user
$ python2 -m ipykernel install--user
$ pip install -U ipykernel
$ jupyter-notebook  

 ubuntu18.0.4 python 开发环境_第1张图片

 

 

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)

 

转载于:https://www.cnblogs.com/bobolog/p/9385414.html

你可能感兴趣的:(ubuntu18.0.4 python 开发环境)