Use PYENV+VIRTUALENV to control the environment version under Mac

Source: Internet
Author: User
Tags eval openssl virtual environment virtualenv

Today I want to build a Django environment find the default Python version is 2.7 but I like more than 3.0 of the version, Wood has a way to build a virtual environment, by the way to record the installation process, easy to view later

Open Terminal

Steps:

1. Installing pyenv

2. Configure the. bash_profile file

3. Installing pyenv-virtualenv

4. Install the Python version using pyenv

5. Create an environment using the PYENV virtualenv version number Environment name command

6.pyenv virtualenv Common Management commands

-----------------------------------------------------

1. Order:Brew Install pyenv

2. command: Open. Bash_profile opening file

Add Content:

Export Pyenv_root=/usr/local/var/pyenv
If which pyenv >/dev/null; Then eval "$ (pyenv init-)"; Fi
If which pyenv-virtualenv-init >/dev/null; Then eval "$ (pyenv virtualenv-init-)"; Fi

Reload. Bash_profile

Command: Bash. bash_profile

3. Order: Brew Pyenv-virtualenv

4. Command: pyenv Install 3.5.2

5. Command: pyenv virtualenv 3.5.2 env3.5.2

6. Common commands:

Pyenv Activate env3.5.2 switch to env3.5.2

    Pyenv versions view all installed Python or Python environment versions under the current version

Command Result: * System (set by/usr/local/var/pyenv/version)

3.5.2

          3.5.2/envs/env3.5.2

          env3.5.2

pyenv Deactivate exiting the current environment

To delete an environment:

Delete Directory

rm-rf/pythontest/.pyenv/versions/env271/

Now you can use the independent environment for development work, you can install the plug-in you need

If you want to configure it in Pycharm, add the environment directly to the project environment.

Step 4 problems encountered, and workaround:

Installing Python-2.7.11 ... Error:the Python zlib extension is not compiled. Missing the zlib? Consult to the Wiki page to fix the Problem.https://github.com/yyuu/pyenv/wiki/common-build-problemsbuild FAILED ( OS X 10.11.5 using Python-build 20160130) Inspect or clean up the working tree At/var/folders/fb/7406jr3s60z_tdpxxqm2s9hh0 000gn/t/python-build.20160616162746.48644results logged to/var/folders/fb/7406jr3s60z_tdpxxqm2s9hh0000gn/t/ Python-build.20160616162746.48644.loglast Log lines:rm-f/users/matrix/.pyenv/versions/2.7.11/share/man/man1/ Python.1 (cd/users/matrix/.pyenv/versions/2.7.11/share/man/man1; ln-s python2.1 python.1) if test "xno"! = "Xno"  ; Then         case No in             upgrade) ensurepip= "--upgrade";;             install|*) ensurepip= "";         ESAC;          ./PYTHON.EXE-E-M ensurepip             $ENSUREPIP--root=/;     fiyujingyao:2.7.11 matrix$ cflags= "-i$ (Brew--prefix OpenSSL)/include" ldflags= "-l$ (Brew--prefix OpenSSL )/lib "pyenv install 3.6-devcloning https://hg.python.org/cpython...error:please install ' mercurial ' and try again

In the terminal, note that the version number of the following code is replaced

cflags="-i$ (Brew--prefix OpenSSL)/include-i$ (Xcrun--show-sdk-path)/usr/include" ldflags="-l$ ( Brew--prefix OpenSSL)/lib "pyenv install3.5.2
Or
Cflags= "-i$ (xcrun--show-sdk-path)/usr/include" pyenv install-v 3.5.2 Reason:
Zipimport. Zipimporterror:can ' t decompress data; Zlib Not available

Use PYENV+VIRTUALENV to control the environment version under Mac

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.