- *nix: install asdf
- asdf python plugin:
asdf plugin-add python
- asdf python plugin:
- windows: install pyenv-win
note: tested on v2.7
$ python
>>> import module.submodule
>>> foo = module.submodule.yourclass()
>>> foo.version()
v1
>>> reload(module.submodule)
>>> foo = module.submodule.yourclass()
>>> foo.version()
v2
note: works on 3.8
#!/usr/bin/env python
# autoload virtualenv.
import os
directory = os.path.dirname(os.path.abspath(__file__))
if os.name == 'nt': # windows
activate = os.path.join(directory, '../your-virtual-env-directory/Scripts/activate_this.py')
else:
activate = os.path.join(directory, '../your-virtual-env-directory/bin/activate_this.py')
execfile(open(activate).read())
# your code here...
note: should word on v2.6+; tested on v2.7
echo '{"foo": "lorem", "bar": "ipsum"}' | python -m json.tool # directly on cli
python -m json.tool my_json.json # json in file.
export PIP_REQUIRE_VIRTUALENV=true
in shell config.