Setting up virtual environment in Windows to contribute to docs from command line


Today I was finally able to figure out the problem I was having setting up a virtual environment (for the purpose of contributing to documentation) using the GitBash command line from Windows. In the ODK docs contribution guide, users are instructed to use the following command:

$ virtualenv -p python3 odkenv

I don’t know if Linux or Mac users are having a problem with this command as well, but it wasn’t working for me. Looking through the Python help forums and what others have posted on Stack Overflow, it looks to me like this command has been deprecated in more recent versions of Python. I ended up having success using the following command:

$ py -m virtualenv odkenv

Then when I attempted to activate my virtual environment, this command from the documentation contribution guide did not work:

$ source odkenv/bin/activate

However, the following command did work:

$ source odkenv/Scripts/activate

Is this just a Windows problem, or is this something that users of all systems need to have updated in the documentation? I am happy to practice using the command line to contribute documentation line edits (or to add information for Windows contributors) if someone more experienced than myself can give me guidance on how relevant my situation might be to all users. Thank you!

(Adam) #2

This might be related to what your built-in version of Python is.

ODK Docs requires Python 3.5+, but most OSes ship with Python 2.7
The virtual environment stuff changed between 2 and 3, so the docs set up stuff tacitly assumes Python 2.7 for creating the virtual environment, while populating the environment with Python 3.x

When you are in your terminal, and no virtual environment is active, type python and see what version it says you have, and let us know.


This is strange, but when I type the python command into my GitBash command line, it seems to just freeze. It returns no errors or output, and if I wait several minutes and eventually close GitBash, a window pops up to ask if I’m sure I want to close GitBash while a process is still running.

However, if I type the python command into DOS, it works just fine. Output there tells me that I have Python 3.6.4.

Thank you so much for your help!