Virtualenv is a tool that lets you create anisolated Python environment for your project. It creates an environment thathas its own installation directories, that doesn’t share dependencies withother
virtualenv
environments (and optionally doesn’t access the globallyinstalled dependencies either). You can even configure what version of Pythonyou want to use for each individual environment. It's very much recommended touse virtualenv
when dealing with Python applications.Install Tensorflow Mac
Choose your macOS deep learning platform — either Catalina or Mojave. These TensorFlow 2.0. With Virtualenv the installation is as follows: Install pip and Virtualenv. Create a Virtualenv environment. Activate the Virtualenv environment and install TensorFlow in it.
Installation
To install
virtualenv
run:Usage
If you have a project in a directory called
my-project
you can set upvirtualenv
for that project by running:If you want your
virtualenv
to also inherit globally installed packages run:These commands create a
venv/
directory in your project where alldependencies are installed. You need to activate it first though (in everyterminal instance where you are working on your project):You should see a
(venv)
appear at the beginning of your terminal promptindicating that you are working inside the virtualenv
. Now when you installsomething like this:It will get installed in the
venv/
folder, and not conflict with otherprojects.To leave the virtual environment run:
Download Tensorflow Mac Virtual Environment Download
Important: Remember to add
venv
to your project's .gitignore
file soyou don't include all of that in your source code.It is preferable to install big packages (like Numpy), or packages you alwaysuse (like IPython) globally. All the rest can be installed in a
virtualenv
.Virtualenvwrapper
To make it easier to work on multiple projects that has separate environmentsyou can install
virtualenvwrapper
. It's an extension to virtualenv
andmakes it easier to create and delete virtual environments without creatingdependency conflicts.To install
virtualenvwrapper
run:Depending on your setup you might need to install it using
sudo
. Read theinstallationdocumentationfor more information.Install Tensorflow Venv
Note:
virtualenvwrapper
keeps all the virtual environments in~/.virtualenv
while virtualenv
keeps them in the project directory.