Python practical environment pyenv build tutorial, pythonpyenv
Experimental System: kubuntu-15.10-desktop-amd64
Introduction to pyenv: We usually Install Multiple Python versions in the operating system. In * nix systems, Python 2 and Python 3 are installed by default, therefore, it is difficult to switch the Python version. pyenv provides a simple method. Pyenv is a tool that can easily switch between multiple Python versions. It is simple and elegant.
Pyenv has the following functions:
Global Python version Switch
Provide the corresponding Python version for a single project
Using Environment Variables allows you to override the Python version
Search commands between different versions at the same time
It has the following features:
1. Install the dependency package in the early stage:
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 git vim
2. Use scripts to quickly install pyenv:
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
3. After the installation is complete, configure the environment variables as prompted by pyenv:
Vim ~ /. Bash_profile --------------------------------------------->
Export PATH = "/home/jason/. pyenv/bin: $ PATH"
Eval "$ (pyenv init -)"
Eval "$ (pyenv virtualenv-init -)"
<------------------------------------------
Source ~ /. Bash_profile // After the editing is saved, make sure it takes effect.
4. test whether the installation is successful and install python of the specified version:
Pyenv-v // check whether the installation is successful
Install python:
Pyenv install -- list | less // view the installable version pyenv install 3.4.2 // specify a version for Installation
Pyenv versions // view the installed version
5. Configure the virtual directory and install ipython:
Mkdir test // create a working directory cd testpyenv virtualenv 3.4.2 test // create a virtual environment based on a specific version
Pyenv local test // set this directory to this environment
Pip install ipython // install ipython for this environment
In use, you can view the virtual environment through pyenv virtualenvs. here we can see that there is already a test.
When I am not working in this directory, the python version is the system's default 2.7.10. When I switch to the test directory, the python version is changed to 3.4.2 I just set, which is very convenient.
6. For additional extensions, use jupyter:
Jupyter is a product that separates IPython and Python interpreters and will gradually replace IPython for independent release. Jupyter can be combined with programs other than Python to provide new and powerful services. For example, Ruby REPL environment IRuby and Julia REPL environment IJulia.
Cd test // enter pip install jupyterjupyter notebook in the virtual environment just now -- ip = 0.0.0.0 // run
The ip address of my VM is 192.168.75.130. Open http: // 192.168.75.130: 8888 in the browser to access the page. Create a python3 page to start running code on the web end. Markdown is also supported here. You can try it on your own.
Here, the demo is over. Thank you for watching it. Thank you!