Python Virtual Environments in Windows, virtualenv, lsvirtualenv, venv

Some commands for Anaconda:
# Which version do I have?
> conda --version
# (recommended me to update the conda using "conda update -n base conda", so...)
> conda update -n base conda
# Following https://www.tensorflow.org/install/install_windows, I ran:
> conda create -n venv_tf python=3.5
(venv_tf) > pip install --ignore-installed --upgrade tensorflow

Can then simply activate it from ordinary command prompt:
> activate venv_tf
— Useful commands from command line:
  • lsvirtualenv to view virtual environments
  • C:\Dev\venv\Scripts\activate to activate the virtual environment located in C:\Dev\venv\
Other notes on PyCharm:
  • PyCharm’s built-in Terminal does NOT work as an external command line. I witnessed different error messages (formatted differently, less detailed) in the built-in Terminal. In one case, python setup.py did NOT work from the built-in Terminal, while the same command worked from a normal command line.
  • If the packages you install need for some reason Visual Studio C++ of some version, it did NOT help me to add to the PATH the directories where my Visual Studio C++ was located (namely, set PATH=C:\Users\%USERNAME%\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64;C:\Users\%USERNAME%\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\WinSDK\Bin\x64;C:\Users\%USERNAME%\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\WinSDK\Bin;%PATH%). Instead, press “Start”, then search for “Visual C++ Command Prompt” or something like that, and this command prompt already includes in its %PATH% variable the relevant directories.
Other notes on python:
  • https://www.lfd.uci.edu/~gohlke/pythonlibs/ — Unofficial Windows Binaries for Python Extension Packages

Leave a Reply

Your email address will not be published. Required fields are marked *