Skip to content

Instantly share code, notes, and snippets.

@lalamax3d
Last active July 14, 2021 15:54
Show Gist options
  • Save lalamax3d/41a40dbb032e4098d44231a19d0b94ef to your computer and use it in GitHub Desktop.
Save lalamax3d/41a40dbb032e4098d44231a19d0b94ef to your computer and use it in GitHub Desktop.
simple conda cheat sheet for my own brain.

CONDA

  • conda info -e
  • jupyter notebook
  • conda create -h
  • conda create -n myenv python=3.7.9 ipython pyside2
  • conda create -n myenv sqlite
  • conda activate myenv
  • activate myenv | source activate myenv
  • deactivate
  • conda search pillow
  • conda install pillow
  • conda install pyqt

if using python 3.5+ - windows

python -m venv %userprofile%.venv\envname

below in bat file to activate

@Echo off
echo Enabling Computer Vision Environment for FACE_IT
SET FILEPATH=%~dp0
cmd /k "%userprofile%\.venv\envname\Scripts\activate & cd /d %FILEPATH%"

if using python 3.6+ - linux ( ubuntu etc )

  • python3 -m ensurepip
  • python3 -m pip install --upgrade pip
  • python3 -m pip install --upgrade pip setuptools wheel --user
  • python3 -m pip install opencv-python opencv-contrib-python imutils --user

setup venv (linux)

  • pip3 install virtualenv
  • which virtualenv
  • source venv/bin/activate

Setup Virtualenvwrapper approach (workon etc.)

  • pip install virtualenvwrapper

  • pip install virtualenvwrapper-win (for windows)

  • in ~/.bashrc file

  export WORKON_HOME=$HOME/.virtualenvs   # Optional
  export PROJECT_HOME=$HOME/projects      # Optional
  • source /usr/local/bin/virtualenvwrapper.sh
  • source ~/.bashrc
  • echo $WORKON_HOME

NOW CREATION USING virtuanenvwrapper and workon combo

  • create venv in CWD
    • virtualenv -p python3 envname
  • create venv in workon home
    • mkvirtualenv envname
    • if above failing (for some pyenv reason etc), cd ~/.virtualenvs
    • python3 -m venv odoo
  • workon envname

Setup Pyenv in linux - 2021 way to go

  • Pre-requist (debian)
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
export PATH="/home/user/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

USAGE pyenv

  • pyenv install --list >> list available python versions (a lot)
  • pyenv versions >> list installed versions and which is current (using - pyenv offcourse)
  • pyenv install 3.7.0
  • pyenv local 3.7.0 >> set it for local development

PIP TIPS

  • Check an installed package version
    • pip3 show pillow
  • Upgrade an installed package to latest
    • pip3 install Pillow --upgrade

Finding an installed package

  • import pysvn
  • pysvn.file >> /usr/lib/python3/dist-packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment