0

i just started learning django and i am very confused in how to set up a virtual environment.

i have successfully installed python:

When i run python --version i get Python 3.8.1

and when i run python3 --version i get Python 3.8.1

My first problem is when i run which -a python3 i get this

/Library/Frameworks/Python.framework/Versions/3.8/bin/python3

/usr/local/bin/python3

/usr/bin/python3

Can someone help me understand why i have 3 locations where python3 exist?

My 2nd problem is i have successfully installed virtaulenv and virtualenvwrapper

when i run virtualenv --version i get:

virtualenv 20.4.3 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/virtualenv/__init__.py

and when i run virtualenvwrapper --version i get:

-bash: virtualenvwrapper: command not found

thats why when i run mkvirtualenv test i keep getting command not found.

My third problem is what is the difference between virtualenv test and mkvirtualenv test?

10
  • So if you go to /usr/local/bin and /usr/bin/ ... and list python3... you will find that there is a soft link. These all python3 will link to the same binary python. Commented Mar 24, 2021 at 5:29
  • @ShivendraPratapKushwaha what do you mean by list python3 to find a soft link? Commented Mar 24, 2021 at 5:35
  • you just can do ls -ld python3 ... in /usr/local/bin and /usr/bin/ path... Commented Mar 24, 2021 at 5:38
  • @ShivendraPratapKushwaha for /usr/local/bin i get lrwxr-xr-x 1 root wheel 69 26 Jan 2020 python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.8/bin/python3 and for /usr/bin/ i get -rwxr-xr-x 1 root wheel 31488 22 Sep 2020 python3 they are not the same, why? Commented Mar 24, 2021 at 5:41
  • so you have two different python3. /usr/bin is distribution managed. /usr/local/bin is not a distribution managed, but a locally package installation. It is not recommended to install your local packages in /usr/bin otherwise it some updates on distribution managed will be impacted... Now if you do echo $PATH. you will see that /usr/local/bin will come before /usr/bin.. so that you can use you local package, and if local package is not found then system will take it from /usr/local i.e. from distribution manager. Commented Mar 24, 2021 at 5:55

1 Answer 1

1

If you are using Ubuntu you can follow the steps below

  1. Go to the folder where you intend to keep your Django project
  2. Run the command python -m venv env
  3. env is the name of virtual env if python doesn't work try with python3
  4. activate environment by source env/bin/activate env is the name of environment.
  5. Install all dependencies make a new folder and import Django project in it.
Sign up to request clarification or add additional context in comments.

3 Comments

I am not using ubuntu, i am trying to install it on Mac Terminal
this works even for mac I am using the same

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.