I used brew to install both python2 and python3
brew install python
brew install python3
I noticed that there are pip and pip3 so which pip should I use to create virtualenv
pip install virtualenv
or pip3 install virtualenv
Use pip install virtualenv
to create a python
env and pip3 install virtualenv
to install a python3
env
The difference is required because if you use pip install virtualenv
and need python3
packages, you will get all kinds of errors!
UPDATE (2020-03-12): With python3 you can also use
python3 -m venv {directory}
where {directory}
is the path of/to your virtualenv.
pip install virtualenv
This doesn't create any virtual environment. That installs virtualenv
program, that is used in order to create virtual environments.
What is the default python version that your virtual environment will have is specified as an argument, when actually making the env, like:
virtualenv -p python3 my_venv
or
virtualenv -p python2 my_venv
regardless on how the virtualenv package was installed.
Furthermore checkout this
Your second question:"how can I know if that virtualenv is the one created by pip or pip3?"
-> You can activate the virtual environment with source bin/activate(first cd in the folder of the environment) When you are sure you are in the virtual environment, type "python --version". You can also check which python is active in the environment by typing "which python". Hope this helps.
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