0320-Anoconda入門

Conda在Windows上的使用

前言

  • 基礎,必學

    Having been involved in the python world for so long, we are all aware of pip, easy_install, and virtualenv, but these tools did not meet all of our specific requirements. The main problem is that they are focused around Python, neglecting non-Python library dependencies, such as HDF5, MKL, LLVM, etc., which do not have a setup.py in their source code and also do not install files into Python’s site-packages directory.
    So Conda is a packaging tool and installer that aims to do more than what pip does; handle library dependencies outside of the Python packages as well as the Python packages themselves. Conda also creates a virtual environment, like virtualenv does.
    As such, Conda should be compared to Buildout perhaps, another tool that lets you handle both Python and non-Python installation tasks.
    Because Conda introduces a new packaging format, you cannot use pip and Conda interchangeably; pip cannot install the Conda package format. You can use the two tools side by side but they do not interoperate either.html

參考

anaconda官方文檔
conda cheet sheet
Conda Docs
Anaconda package list
Conda 半小時入門操做
PYTHON PACKAGES AND ENVIRONMENTS WITH CONDA
Jupyter Notebook interact widgetspython

學習內容

Conda常識

  • Conda雖然是一個包管理工具,可是不經過conda install的包貌似不能在conda list中顯示出來
  • 手動經過setup.py安裝的包,不能在conda list中顯示
  • 除了package management功能以外,還有環境建立和管理功能,另外還提供Jupyter notebook神器,spyder IDE等。

手動安裝的包不能list出來

conda package --untracked
# 能夠查看文件以查看哪些包已經安裝了

Python 2 or Python 3

  • conda update moves up to the latest compatible version, while conda install can be used to install any version. For example, if Python 2.7.7 is currently installed but the latest version of Python 2 is 2.7.12 and the latest version of Python 3 is 3.5.2, then conda update python will install Python 2.7.12, while conda install python=3will install Python 3.5.2. Conda uses the same rules for other packages, so conda install can always install the highest version, and conda update will always install the highest version with the same major version number.

Conda經常使用命令

conda list
conda update
conda update anoconda
conda update --all
conda info
conda info --envs
# 搜索
conda search beautifulsoup4
# 從網站下載安裝包
conda install --channel https://conda.anaconda.org/pandas bottleneck 
# 建立和激活環境
conda create --name snowflakes biopython
activate snowflakes
# 第二個環境,python版本變化,包含兩個包
conda create --name bunnies python=3 astroid babel
# 複製一個環境
conda create --name flowers --clone snowflakes
# 切換環境
activate bunnies
deactivate
# 刪除環境
conda remove --name flowers --all
# 刪除包
conda remove --name bunnies iopro
# 重置環境,會刪除全部緩存的包,文件,源代碼等
conda clean --all

安裝non-conda包

  • 使用pip
  • 使用傳統的setup.py

windows下添加環境變量

D:\ProgramData\Anaconda3
D:\ProgramData\Anaconda3\Scripts
D:\ProgramData\Anaconda3\Library\bin

Python 路徑下文件夾含義

  • Jupyter基本配置

jupyter notebook --generate-config
# 生成配置文件,查看配置文件路徑
# 打開 users/zhens/.jupyter/jupyter_notebook_config.py
# 搜索 # The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = u'E:\Master-Thesis'
相關文章
相關標籤/搜索