my cheat sheet on pipy
1 Postman
https://<addr>/<root>/<data store>/<[yang module:]container>/<leaf>/?<optoins>/
- GET
/restconf/data/netconf-state/capabilities
2 Python Virtual Environment (pyenv)
Note: for me this is deprecated. As of 2022 I am exclusively using the
python standard library included venv
module, i.e. python -m venv mynewvenv
but, it could still be useful to me in the future when I come across pyenv.
2.0.1 bash works, but so do other shells.
- pyenv versions
- pyenv –version
- ls -la ~/.pyenv/shims
- PATH=/Users/zintis/.pyenv/shims
- pyenv commands
2.0.2 Solution: May 15th, 2019
Added this to my .cshrc
- set path = ( ~/.pyenv/shims $path )
- alias 2.7 'setenv PYENVVERSION 2.7.16'
- alias 3.6 'setenv PYENVVERSION 3.6.5'
Now I can swap python versions by typing 2.7 or 3.6
2.1 switching back and forth in bash
- python –version
- pyenv shell 2.7.11
- python –version
- which python
- pyenv shell 2.7.16
- python –version
- printenv PYENVVERSION
- pyenv shell 3.6.5
- printenv PYENVVERSION
- python –version
2.2 switching back and forth in tcsh
- 3.6
- python –version
- which python
- pyenv versions
- printenv PYENVVERSION
- 2.7
- python –version
- which python
- pyenv versions
- printenv PYENVVERSION
2.2.1 manual:
- setenv PYENVVERSION 2.7.16
- setenv PYENVVERSION 3.6.5
pyenv install -v 2.7.16 CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \ eval "$(pyenv init -)" printenv # only pertinent variables are shown here: TERM_PROGRAM=Apple_Terminal PYENV_ROOT=/Users/zintis/.pyenv PYENV_VERSION=2.7.16 GROUP=staff USER=zintis PATH=/Users/zintis/.pyenv/shims:/Users/zintis/.pyenv/versions/3.6.5/bin:/usr/lcoal/bin:/usr/bin:/bin:/usr/sbin:/Users/zintis/.local/bin:/Users/zintis/.pyenv/versions/3.6.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware:Fusion.app/Contents/Public:/opt/X11/bin:/usr/local/bin/jamf:/Users/zintis/.local/bin:/usr/local/sbin:/usr/local/bin/ PYENV_SHELL=bash
2.3 Activating Environments using virtualenv
Note: for me this is deprecated. As of 2022 I am exclusively using the
python standard library included venv
module, i.e. python -m venv mynewvenv
but, it could still be useful to me in the future when I come across pyenv.
2.3.1 Installing a virtual environment
Virtual enevironments are installed under the directory where the command
virtualenv name
is run.
So one should cd
to the directory first, before running these commands.
My convention has been to have ~/bin
as my root directory for python environment
which means that running virtualenv newname
will create a directory
~/bin/newname
with all the links and added environment files below this directory.
2.3.2 First create the virtual environment (under ~/bin directory)
virtaulenv name
# This creates the virtual environment named 'name'virtualenv name --python=python3
# Specify the Python verion in this named environment
2.3.3 Once created activate and deactive the virtual environment (under ~/bin directory)
source name/bin/activate
# Active this virtual environment (if you work in bash)source name/bin/activate.csh
# (if you work in tcsh or csh, which of course I do.)deactivate
# Deactive it. Does this delete the files? I'm guessing NO
cd to bin/ directory under the virtual environemnt root directory source name/bin/activate.csh
As of May 31st, 2019 I have three virtual environments set up:
- ~/bin/venv-controllers-2.7
- ~/bin/venv-prog-basics
- ~/bin/venv-xpress
Note: the programs used for venv-xpress are under ~/bin/dnav3 directory
2.4 Activating Environments using venv module (python3.4 and later)
Note: As of 2022 I am exclusively using the python standard library included
venv
module, i.e. python -m venv mynewvenv
2.4.1 Installing a virtual environment
Virtual enevironments are installed under the directory where the command
python3 -m venv name
is run.
So one should cd to the directory first, before running these commands.
My convention has been to have ~/bin as my root directory for python environment
which means that running python3 -m venv newname
will create a directory
~/bin/newname with all the links and added environment files below this directory.
2.4.2 First create the virtual environment (under ~/bin directory)
python3 -m venv name
# This creates the virtual environment named 'name'python3 -m venv name
# ONLY works for python3, NOT python2
2.4.3 Once created activate and deactive the virtual environment (under ~/bin directory)
source name/bin/activate
# Active this virtual environment (if you work in bash)source name/bin/activate.csh
# (if you work in tcsh or csh, which of course I do.)deactivate
# Deactive it. Does this delete the files? I'm guessing NO
cd to bin/ directory under the virtual environemnt root directory source name/bin/activate.csh
Note: the programs used for venv-xpress are under ~/bin/dnav3 directory
3 Pip (Python Install Packages)
Here is PyPi Search "cisco" here, or "cisco ACI" and get libraries already written.
3.1 pip commands
[ ]
pip intall package[ ]
pip install –upgrade package[ ]
pip uninstall package[ ]
pip freeze[ ]
pip list[ ]
pip list -o # only list the outdated modules (slow)[ ]
pip list –outdated # same thing[ ]
pip install -r requirements.txt[ ]
pip install –upgrade pip # to have pip upgrade itself.[ ]
pip install -U pip * important to keep pip up to date to close security holes
4 acicobra and acitools
python setup.py install
5 Mac OSX
#setenv PYTHONPATH /Library/Frameworks/Python.framework/Versions/3.5