IN THIS ARTICLE
- Outlines how to use virtual environments when using Qumulo REST API
- Python virtualenv
- Creating Virtual Environments for Python 2.7
- Python on CentOS
- Python on Windows
- Other languages
- Virtual environment utilizing REST API
For python users using the Qumulo REST API, we currently require version 2.7 of Python. In some environments (such as OSX Yosemite), 2.7 is the default version of of the Python interpreter, but in other environments such as CentOS, version 2.6 or other versions may be the system default. This means that we cannot assume that the installed version of Python on a given system will match our requirements for using the Qumulo REST API.
The Hitchhiker’s Guide to Python has a great chapter on virtual environments and the tool virtualenv:
"virtualenv is a tool to create isolated Python environments. virtualenv creates a folder which contains all the necessary executables to use the packages that a Python project would need."
Virtualnv is essentially all you need to isolate your Python applications and dependencies from the system defaults and other applications. It's recommended to use virtualenvwrapper as a convenience tool around virtualenv since it installs some nice conveniences such as the workon command:
➜ ~ workon
The packages currently installed in my qumulo1212 virtual environment is shown below. Note that the prompt now shows the currently-used virtual environment.
➜ ~ workon qumulo1212
If I run deactivate to unload my virtual environment or use the system environment again, note the difference in installed libraries.
➜ ~ pip list
Creating Virtual Environments for Python 2.7
You can even create virtual environments for a specific version of Python — in our case, we use Python 2.7.
mkvirtualenv foo --python=python2.7
It does assume that you have the specified version of python already installed/available to use:
- on a Mac you can use homebrew to install versions of python
- apt-get on linux variants and CygWin on Windows.
Stack Overflow has a good overview article on this here.
Python on CentOS
Python on Windows
The Hitchhiker’s Guide has a good section on installing Python 2.7 under Windows which you can read here.
Other Languages (Ruby, Node.js, etc.)
You should now be able to successfully utilize virtual environments when using Qumulo REST API
Like what you see? Share this article with your network!