I'm following the instructions for setting up to work with Python on a Mac (http://docs.python-guide.org/en/latest/starting/install/osx/)
It suggests to store the virtual environment created by virtualenv in the project directory... which is of course a git repo.
Is there any reason not to add the virtualenv to the git repo? It seems the natural thing to do, but ...
Check the $VIRTUAL_ENV environment variable. The $VIRTUAL_ENV environment variable contains the virtual environment's directory when in an active virtual environment. Once you run deactivate / leave the virtual environment, the $VIRTUAL_ENV variable will be cleared/empty.
It is generally good to have one new virtual environment for every Python based project you work on. So the dependencies of every project are isolated from the system and each other. How does a virtual environment work?
Make sure that virtualenv has been installed correctly. Check in the python scripts subfolder - there must exist an .exe named virtualenv.exe . If not, uninstall will pip uninstall virtualenv and install again.
VirtualEnv helps you create a Local Environment(not System wide) Specific to the Project you are working upon. Hence, As you start working on Multiple projects, your projects would have different Dependencies (e.g different Django versions) hence you would need a different virtual Environment for each Project.
Always try to check in the source, not the result of running a process.
A virtualenv is rather platform specific; a Windows virtualenv may require different binaries than one created on Linux. The paths in the script files will almost certainly use absolute paths, not relative paths, tying a virtualenv to a specific location on your harddisk.
Instead, check in instructions on how to recreate a virtualenv. Include the commands, and use tools like pip
, zc.buildout
or Pipenv to let others recreate the right environment for their platform.
pip
lets you install packages into a virtualenv with a requirements.txt
file. You'd commit that file. zc.buildout
lets you define complex build configurations in .cfg
files. Commit those. Pipenv tracks the top level dependencies in Pipfile
and creates a Pipenv.lock
file for perfectly reproducible environments, check in these two files, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With