一般在做用 python 時,最常用到的三個 packages.
1. pip: 取代 easy_install. 是 python 最常用的 package manager
2. virtualenv: environment manager, 主要是自由切換 python2.x and python3.x. 不是很好用,也不常用。不過為了相容性,還是會 install.
3. Numerical packages (numpy, scipy, matplotlib, etc.), 或是用 Enthough, 或是 python(x,y).
一個好消息是只要 install anaconda python, 可以集三者為一。不用再 install above!
Task | Conda package and environment manager command | Pip package manager command | Virtualenv environment manager command |
---|---|---|---|
Install a package | conda install $PACKAGE_NAME | pip install $PACKAGE_NAME | X |
Update a package | conda update --name$ENVIRONMENT_NAME $PACKAGE_NAME | pip install --upgrade $PACKAGE_NAME | X |
Update package manager | conda update conda | Linux/OSX: pip install -U pip Win: python -mpip install -U pip | X |
Uninstall a package | conda remove --name$ENVIRONMENT_NAME $PACKAGE_NAME | pip uninstall $PACKAGE_NAME | X |
Create an environment | conda create --name$ENVIRONMENT_NAME python | X | cd $ENV_BASE_DIR; virtualenv$ENVIRONMENT_NAME |
Activate an environment | source activate $ENVIRONMENT_NAME | X | source$ENV_BASE_DIR/$ENVIRONMENT_NAME/bin/activate |
Deactivate an environment | source deactivate | X | deactivate |
Search available packages | conda search $SEARCH_TERM | pip search $SEARCH_TERM | X |
Install package from specific source | conda install --channel $URL$PACKAGE_NAME | pip install --index-url $URL $PACKAGE_NAME | X |
List installed packages | conda list --name $ENVIRONMENT_NAME | pip list | X |
Create requirements file | conda list --export | pip freeze | X |
List all environments | conda info --envs | X | Install virtualenv wrapper, then lsvirtualenv |
Install other package manager | conda install pip | pip install conda | X |
Install Python | conda install python=x.x | X | X |
Update Python | conda update python * | X | X |
- conda update python updates to the most recent in the series, so Python 2 to latest 2.x, Python 3 to latest 3.x, and so on.
沒有留言:
張貼留言