Python Environment Build (Mac OS) __python

Source: Internet
Author: User
Tags eval rehash virtualenv install pandas install matplotlib pycharm community edition
1 Tools for the MAC OS platform Python environmentPycharm Community Edition Homebrew pip pyenv pyenv-virtualenv- 2 Pycharm

Pycharm is a better IDE for the Python development environment under Mac OS, with business and community editions and free Community editions.
Baidu Search the tool, to its official website to download, and then installed according to requirements. 3 Homebrew

The missing Package manager for MacOS
Home page explain it for Mac OS platform some package Manager 3.1 installation

To its official website, write a blog when the official website provided by the method is in the terminal input the following command
/usr/bin/ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"
Default installation software path:/usr/local/cellar 3.2 Basic Command Summary

Main command Brew Install package name #安装包 Brew List #显示已经安装的包 brew uninstall #卸载 Brew help #打印命令 Brew help cmd #打印具体命令帮助4 pip

As the name implies, the Python Package Manager, installed through the pyenv will automatically install 5 pyenv 5.1 requirements and features

Because of the multiple Python version, sometimes we need to install different versions of Python for different projects. The beauty of pyenv is that instead of using a highly coupled way of implanting different paths into different shells, it simply inserts a gasket path (**SHIMS) at the top of the **path~/.pyenv/shims:/usr /local/bin:/usr/bin:/bin. All searches of the Python executable file are first intercepted by this shims path, which overhead the system path behind. 5.2 Installation

Pyenv's GitHub page provides complete installation and usage guidance, and this article only summarizes and practices the Mac OS environment.
Make sure the homebrew is installed
1) Installation

$ brew Update
$ brew Install pyenv

2) Enable shims and autocompletion.

$ Echo ' eval ' $ (pyenv init-) "' >> ~/.bash_profile

Results

$ cat. Bash_profile 
eval "$ (pyenv init-)"

Note:. Bash_profile may not exist and can be created in the current home directory

$ exec $SHELL
5.3 Command

1) pyenv Commands
List the commands provided by pyenv
2) Pyenv Rehash
Rebuilding shims (including path slicing and automatic completion commands)
3) pyenv Install version
Install a Python version, install to Pyenv_root, default is ~/.pyenv
4) pyenv Install list
To view an installable version of Python
5) Pyenv Uninstall
Uninstall a Python version
6) Pyenv version
Displays the currently active version
7) Pyenv versions
Displays the version of the native installation, * Specifies the currently active version
8) Pyenv which
Current version Path
9) Pyenv Local
Pyenv Local 2.7.6
Creates a file in the current path. Python-version, and writes the above version number in this file, overriding the global when executing the Python command, in this version
Pyenv local--unset Clear localized settings
) Pyenv Global
Global Settings ~/.pyenv/version

The main command pyenv install list is to install the Python counterpart version pyenv install install a version shown above PYENV Global to set up a global version that can be viewed through pyenv versions, where * Specifies the current active version pyenv rehash reset shims and command completion

problem
Prompt zlib not installed
Install command line tools,
CMD input Xcode-select–install
Https://github.com/pyenv/pyenv/wiki/Common-build-problems 6 pyenv-virtualenv

Website address 6.1 requirements and functions

Pyenv also in the form of Pyenv-virtualenv plug-in support virtualenv, what meaning, in fact, pyenv has solved the problem of multiple versions, but each Python version, the project needs may install a variety of packages such as NumPy (Matrix package), SciPy (phenomenon algebra/optimization), Pandas (data analysis), Matplotlib (drawing, hehe, similar to MATLAB drawing), Scikit-learn (machine learning Library), which has the need for separate management. These packages are all installed in Site-packages.
Pyenv-virtualenv's approach is to clone a version of Python that you already have, and then all packages are installed in the cloned version of the path, which is equivalent to customizing the entire Python environment for the project, including the Python version + package. 6.2 Installation

Open the official website view installs the method, this blog is based on the Mac OS environment, has installed good homebrew.
1) Installation
Brew Install Pyenv-virtualenv
Pyenv is also best installed through brew.

2) Set
$ Echo ' eval ' $ (pyenv virtualenv-init-) "' >> ~/.bash_profile
The above configuration is written to. Bash_profile, which provides automatic activate/deactivate, according to the. Python-version, that is, the setting of the global pyenv global
My Computer Configuration

$ cat. Bash_profile 
eval "$ (pyenv init-)"
eval "$ (pyenv virtualenv-init-)"

3) Restart Shell
$ exec "$SHELL" 6.3 basic commands PYENV commands can see integrated virtualenv command Interpretation pyenv virtualenv 2.7.10 my-virtual-env-2.7.10 clone 2.7 .10 version, Target is my-virtual-env-2.7.10, path/users/tl/.pyenv/versions pyenv Virtualenvs list clone version pyenv uninstall My-virtual-env Delete the clone version 6.4 usage pyenv versions list all Python versions of the current computer pyenv virtualenv version number target clone PYENV Global version number set just cloned version This number installs the Machine learning library (for example)

$ pip Install numpy
$ pip install scipy
$ pip install matplotlib
$ pip Install Pandas
$ pip Install Scikit -learn
Pycharm Set Python path
Pycharm-> Preferences-> Project-> project, interpreter ADD Local

Reference articles
1 pyenv

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.