Pew represents for Python Env Wrapper, it is a set of commands to manage multiple Python virtual environments. Pew can create, delete and copy your environments, using a single command to switch to them wherever you are, while keeping them in a single (configurable) location.
Pew builds abstractions on top of virtualenv package.
Install Pew by using pip,
$ pip install --user pewCheck Pew installation by running the following command:
$ pew versionInstead, you can use Nix to install Pew on Nixos as well as other Linux distributions or Macos. For your knowledge, nix is a purely functional package manager on *nix systems, such as Linux, MacOS. If you don't have that on your system, please run this command to install,
Install nix on Linux and MacOS with multi-user mode,
$ bash <(curl -L https://nixos.org/nix/install) --daemonThen validate the nix installation by running the following command:
$ nix --versionNext, you can use nix to install Pew.
$ nix-env -iA nixpkgs.pewPew is completely shell-agnostic and thus works on bash, zsh, fish, powershell, etc.
To create a virtual environment, use new command like below:
$ pew new <envname>The virtual environments would be created under the direction of virtualenv WORKON_HOME. For my case, I am on Ubuntu,
the diretory is ~/.virtualenvs.
There are more options with the new command,
$ pew new --help
usage: pew [-h] [-p PYTHON] [-i PACKAGES] [-r REQUIREMENTS] [-d] [-a PROJECT] envnameFor example, if you like to install Python packages when initializing the virtual environment,
$ pew new -i <package1> -i <package2> <envname>Or, if you have a list of Python packages in requirements.txt, then do this:
$ pew new -r requirements.txt <envname>List or change working virtual environments.
$ pew workon <envname>If no envname is given, then the list of available virtual environments would be printed to stdout.
Once inside the virtual environment, you can use pip to install additional Python packages like this:
$ pip install <package-name>To uninstall the Python package,
$ pip uninstall <package-name>To deactivate current virtual environment by running this command:
$ exitTo remove one or more environments from the WORKON_HOME directory,
$ pew rm <envname1> <envname2> ...By using different Python versions,
$ pew new --python <python-version> <envname>For example,
$ pew new --python python3.10 testenv10$ pew new --python python3.11 testenv11$ pew new --python python3.12 testenv12Besides, Since 0.1.16, Pew integrates Pythonz, which allows you to easily install a new python version (only on linux and macosx). For more details, please refer to Pythonz: a Python installation manager.
Happy coding!