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 --version
conda update conda
conda 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 --version
to deactivate deactivate
conda create --name <new env name> --clone <existing env name>
Example:
conda create --name python3copy --clone python3
conda remove --name <env name> --all
Example:
conda remove --name python3 --all
conda list
conda list --explicit > <filename>
Example:
conda list --explicit > DEV/env.txt
Example: 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.yaml
cd <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.bat
Edit .\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.sh
Edit ./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_TEST
Check it works on activate/deactivate the environment
conda search --full-name <package name>
Example:
conda search --full-name python
conda install <package name>
or
conda install <package name> = <package version>
Example:
conda install pip
or
conda install pip=9.0.1
Check 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.gz
Or
pip install .
Or
python setup.py install
conda update <package name>
or
pip install --upgrade <package name>
Example:
conda update pip
conda remove <package name>
Example:
conda remove pip
Conda tracks changes in the libraries via revisions
conda list --revisions
conda install --revision 2
conda 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.bz2
conda install -c <your anaconda.org username> custom-bundle
rm -rf <anaconda install directory>
Example:
rm -rf ~/anaconda
On Windows remove from the installed programs. Example
rmdir /s anaconda
Like R
conda install -c r r-essentials
conda update -c r r-essentials
pip install pipreqs
pipreqs /path/to/project
Note 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