Mac under Ipython+notebook

Source: Internet
Author: User
Tags builtin virtual environment virtualenv jupyter jupyter notebook

Python for the installation and configuration of data analysis-related tools, and the introduction of NumPy

Why do you use Python for data analysis ?
    • MATLAB

    • R language, syntax similar to C language, But it is semantically a function design language, but also open source.

    • python benefits:

      • A large number of libraries provide complete toolchain for data analysis and processing

      • Python has a lot of libraries, and the library has been increasing, the implementation of the algorithm more innovative. Numpy, Matplotlib, Scipy,scikit-learn

      • Python can also be interfaced with many other languages, such as C

      • with respect to R and Matlab,python can also do a variety of other things, web development, crawlers, scripts, operations, machine learning.

the environment for Python data analysisinstallation and use of ANACONDAWhat is Anaconda

A cross-language, cross-system Package management, environment management tool

Features of Anaconda:

    • Open source

    • Easy to use, easy to install

    • Support for Python and R languages

:

https://www.anaconda.com/download/

installation Process

Windows Note:

    • Choose just for me option

    • Add to Path

    • After installation: Anaconda Navigator, Anaconda prompt, Jupyter notebook

Linux Note:

    • Add to the. bashrc file, and source this file

After the installation is complete, how to check if the installation is successful:

conda --version

Upgrade to the latest version

conda update conda

change the address of the source to the domestic:

Tsinghua Source Address:

https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

Configure the domestic source:

# Add Tsinghua Source
--add Channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
--add Channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
# Set the URL of the source to be displayed at the time of download
Yes
# See if the source has been added successfully
--show Channels
Configuring the environment with CondaCreate an environment
# Create an environment named Py35, specifying a python version of 3.5
# (whether the designation 3.4,3.5,conda will automatically find the latest version for us)
Conda Create--name py35 python=3.5
Activating the Environment
# Direct Activate activation under Windows
Activate py35
# under Linux or Mac, activate with source activate
SOURCE Activate Py35

After activation, you will notice that there is a py35 in front of the command line of the console, which means we have entered the PY35 environment.

# Windows exits the environment
Deactivate py35
# Linux Exit Environment
SOURCE Deactivate py35
# Delete Environment
Conda Env Remove-n py36
use Conda to do package management

To view packages that have already been installed

# view packages in the current environment, installed packages and corresponding versions
Conda List
# view packages within a specified environment
-N py35

Find a Package

# Find out if the specified package can be installed through Conda
# will return the information of this package, if you can see the relevant information, the package may be installed with Conda
Conda Search NumPy
# If the card is not moving, there may be network reasons, you can use the--offline parameter
--offline

Install package

# Install NumPy with Conda
# if NumPy is already installed, you will be prompted to install
Conda Install NumPy

Update package

# Update packages with Conda
Conda Update NumPy

Uninstalling packages

Conda Remove NumPy

The above is Conda to package installation, update, uninstall. It is worth mentioning that Conda Conda, Python, and Pip are considered packages, so you can use Conda to manage versions of Conda and Python, such as:

# Update Conda to the latest version
Conda Update Conda
# The same, can be more anaconda to the latest version
Conda Update Anaconda
# Update Python
# For example we are now python3.5.5, execute the following command and update to the latest version of python3.5.x
Conda Update python
the relationship and difference between Conda and Virtualenv/pip

First of all, Anaconda contains navigator, prompt, Conda, jupyter tools, but also includes the Python, Pip, virtualenv and other tools library

Conda and Pip relationships:

    • Conda is a package management and environment management tool, Conda also supports the management of multiple environments, including Python, R, and note: including the language itself, not just the language of the package

    • Pip is just a Python package management tool

    • Conda does not affect the python that comes with the system

The relationship between Conda and virtualenv

    • Conda is a combination of Pip and virtualenv features

    • Conda can create multiple Python versions of a virtual environment

    • Virtualenv can only create a specified version of the environment

How to determine the management of a virtual environment

# View the absolute path of the PIP
which PIP
# See what the PIP in the current environment is using Python
$ (which PIP)

We can edit the first line in the PIP file to change the Python interpreter used by our PIP

vim $(which pip)

#! /users/guye/anaconda/envs/py35/bin/python
?
#-*-Coding:utf-8-*-
ImportRe
ImportSys
?
from pip. _internal import main
?
if __name__ = = ' __main__ ':
   sys. Argv[0] = re. Sub (r ' (-script\.pyw?| \.exe)? $ ', ", sys. Argv[0])
   sys. Exit (main ())

Or you can directly write the absolute path of PIP to install the package

use of JUPYTER notebookStart Juypter
# Start Jupyter on default address and port

# starts at the specified address and port
--ip=--port=8000

Custom Jupyter

# Create a directory. Jupyter/custom
-P ~/.jupyter/custom
# Add edit custom.js or Custom.css
Vim Custom.js
# write JavaScript code inside the JS file

Mac under Ipython+notebook

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.