Install venv with this command:
pip install virtual env
Create a directory andtype the following command in terminal:
python -m venv virtual <--"The last word in command is the name of the venv, you can call it whatever you want."
Activate virtual environment:
source virtual/bin/activate
#open directory with terminal where you crated vertual environment#python3 -m venv data_analysis_env#example your venv name <visualscrapy>
teamspirit:~$ cd visualscrapy
#teamspirit:~/visualscrapy$ <-- output#Now type bellow command
source ./bin/activate
#(visualscrapy) teamspirit:~/visualscrapy$ <-- output
# Virtual Environments ("virtualenvs") keep# your project dependencies separated.# They help you avoid version conflicts# between packages and different versions# of the Python runtime.# Before creating & activating a virtualenv:# `python` and `pip` map to the system# version of the Python interpreter# (e.g. Python 2.7)
$ which python
/usr/local/bin/python
# Let's create a fresh virtualenv using# another version of Python (Python 3):
$ python3 -m venv ./venv
# A virtualenv is just a "Python# environment in a folder":
$ ls ./venv
bin include lib pyvenv.cfg
# Activating a virtualenv configures the# current shell session to use the python# (and pip) commands from the virtualenv# folder instead of the global environment:
$ source ./venv/bin/activate
# Note how activating a virtualenv modifies# your shell prompt with a little note# showing the name of the virtualenv folder:(venv) $ echo "wee!"# With an active virtualenv, the `python`# command maps to the interpreter binary# *inside the active virtualenv*:(venv) $ which python
/Users/dan/my-project/venv/bin/python3
# Installing new libraries and frameworks# with `pip` now installs them *into the# virtualenv sandbox*, leaving your global# environment (and any other virtualenvs)# completely unmodified:(venv) $ pip install requests
# To get back to the global Python# environment, run the following command:(venv) $ deactivate
# (See how the prompt changed back# to "normal" again?)
$ echo "yay!"# Deactivating the virtualenv flipped the# `python` and `pip` commands back to# the global environment:
$ which python
/usr/local/bin/python
How to make a virtual environment in Python! (Windows)
py -m venv [virtual environment name][virtual environment name]Scriptsactivate #use "" not "/"
DO YOUR CODE IN HERE, SAVES TIME WITH PACKAGE MANAGEMENT!
(tutorial-env) $ pip search astronomy
skyfield - Elegant astronomy for Python
gary - Galactic astronomy and gravitational dynamics.
novas - The United States Naval Observatory NOVAS astronomy library
astroobs - Provides astronomy ephemeris to plan telescope observations
PyAstronomy - A collection of astronomy related tools for Python....
# At its core, the main purpose of Python virtual environments is to # create an isolated environment for Python projects. This means that # each project can have its own dependencies, regardless of what # dependencies every other project has.
(tutorial-env) $ python -m pip install novas
Collecting novas
Downloading novas-3.1.1.3.tar.gz (136kB)
Installing collected packages: novas
Running setup.py install for novas
Successfully installed novas-3.1.1.3