Complete and practical guide how to setup python project
Download anaconda from https://www.continuum.io/downloads for windows/mac/linux with python2/python3
Follow the instructions and install it.
conda --help
conda --version
conda list
python --versionconda update condaconda create -n [env_name] python=[python_version]Examples:
conda create --name python2 pip
conda create --name python3 python=3.6- python2, python3 - names of environments that are created by default in the envs directory in your conda directory
- pip - package to be installed to the env. You can specify as many packages as you need in the end of command line, separated by space
- python= - gives possibility to specify python version to be used as a default in the env
conda info --envs
(Linux)
source activate [env_name]
and (Windows)
activate [env_name]
Example: source activate python3 and activate python3
Check that packages are from the activated env: Examples:
python --version
pip --versionto deactivate deactivate
conda create --name <new env name> --clone <existing env name>Example:
conda create --name python3copy --clone python3conda remove --name <env name> --allExample:
conda remove --name python3 --allconda listconda list --explicit > <filename>Example:
conda list --explicit > DEV/env.txtExample: file
environment.yaml
Content:
name: stats
dependencies:
- numpy
- pandas
- python=3.6
- pip:
- Flask-Testing
conda create --name <env> --file <filename>Example
conda create --name python3new --file environment.yamlcd <anaconda folder>/envs/<env name>
mkdir .\etc\conda\activate.d
mkdir .\etc\conda\deactivate.d
type NUL > .\etc\conda\activate.d\env_vars.bat
type NUL > .\etc\conda\deactivate.d\env_vars.batEdit .\etc\conda\activate.d\env_vars.bat
set MY_ANACONDA_TEST='Hello World'Edit .\etc\conda\deactivate.d\env_vars.bat
set MY_ANACONDA_TEST=Check it works on activate/deactivate the environment
cd <anaconda folder>/envs/<env name>
mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d
touch ./etc/conda/activate.d/env_vars.sh
touch ./etc/conda/deactivate.d/env_vars.shEdit ./etc/conda/activate.d/env_vars.sh
#!/bin/sh
export MY_ANACONDA_TEST='Hello World'Edit ./etc/conda/deactivate.d/env_vars.sh
#!/bin/sh
unset MY_ANACONDA_TESTCheck it works on activate/deactivate the environment
conda search --full-name <package name>Example:
conda search --full-name pythonconda install <package name>or
conda install <package name> = <package version>Example:
conda install pipor
conda install pip=9.0.1Check pip location: (Mac/Linux): which -a pip (Windows): where pip
Check python location: (Mac/Linux): which -a python (Windows): where python
Only if you activated env! otherwise it will be install to different directory :
Remote file
pip install <package>Local file:
pip install relative_path_to_seaborn.tar.gzOr
pip install .Or
python setup.py installconda update <package name>or
pip install --upgrade <package name>Example:
conda update pip
conda remove <package name>Example:
conda remove pipConda tracks changes in the libraries via revisions
conda list --revisionsconda install --revision 2conda metapackage custom-r-bundle 0.1.0 --dependencies r-irkernel jupyter r-ggplot2 r-dplyr --summary "My custom R bundle" conda install anaconda-client
anaconda login
anaconda upload path/to/custom-bundle-0.1.0-0.tar.bz2conda install -c <your anaconda.org username> custom-bundlerm -rf <anaconda install directory>Example:
rm -rf ~/anacondaOn Windows remove from the installed programs. Example
rmdir /s anacondaLike R
conda install -c r r-essentials
conda update -c r r-essentialspip install pipreqs
pipreqs /path/to/projectNote Works for pybuilder project
- http://pybuilder.github.io/
- Basic Tutorial: http://pybuilder.github.io/documentation/tutorial.html
- List of available plugins: http://pybuilder.github.io/documentation/plugins.html
- Project examples using PyBuilder: http://pybuilder.github.io/documentation/examples.html
pip install pybuilder
NOTE!!! for Windows use command pyb_ instead of pyb
Installing dependencies and building with default goal
pyb --start-project
pyb install_dependencies publish
pyb
pyb install_dependencies
pyb
pyb -t
pyb -P spam="spam message"
build.py:
use_plugin('python.pycharm')
Command line:
pyb pycharm_generate
build.py:
use_plugin('python.pydev')
Command line:
pyb pydev_generate
.travis.yml file
pytest pytest-cov libraries