0

I am new to programming. I recently started learning Django by following the tutorials on Mozilla. I created a python virtual environment by following the steps in the tutorial. However, I am not able to activate the virtual environment that I have created. As . a result, I am not able to progress on the tutorials. I have spent hours trying trying to find a solution on Google, but nothing seems to work. I have attached a picture of the terminal window where you can see the commands I am entering and the results.

hemantasundaray@Deepaks-MacBook-Pro ~ % source createdenv/bin/activate
source: no such file or directory: createdenv/bin/activate
hemantasundaray@Deepaks-MacBook-Pro ~ % ls virtualenv
ls: virtualenv: No such file or directory
hemantasundaray@Deepaks-MacBook-Pro ~ % workon 
zsh: command not found: workon
hemantasundaray@Deepaks-MacBook-Pro ~ % 

What am I doing wrong?

enter image description here

James Z
  • 12,209
  • 10
  • 24
  • 44
HKS
  • 526
  • 8
  • 32

1 Answers1

0

Basically virtual environment is to isolate your python packages so that they don't interfere with system wide packages.

My suggestion your question is, cd to the folder where you want your project to reside, and create the virtual environment. My suggestion is please go with pipenv to create virtual environment. It made by Kenneth Reitz and it's awesome, github link

If you want to install pipenv, simply install with pip or apt if you are on ubuntu, or with brew if you are on mac, You can also use the pip provided by python to install pipenv,

      sudo apt install python3-pipenv 

or you could install it with pip,

      pip3 install pipenv

or for mac use, follow the answer

      brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/2c0bbfa297e2429cd6e080ad5231f3aa56ff4f65/Formula/pipenv.rb

pipenv

To install django, simply activate the virtual environment with the above pipenv shell command and run

    pipenv install django

eg: - If you want to create a new django django_project_you_fancy, I would do,

        mkdir my-django-project
        cd my-django-project
        pipenv shell

This would create a Pipfile, next time whenever you want to use the virtual environment, simple cd into the folder and type pipenv shell

enter image description here

Simple run the django-admin commands to creating project and get started with the fun.

     django-admin startproject django_project_you_fancy

manage.py

Arvind
  • 13
  • 1
  • 4
  • Can you pls let me know why the workon command in my terminal is showing the response "command not found"? – HKS Nov 28 '19 at 19:18
  • There can be many reason, most prolly the workon command is not set in the PATH, You can simply export or add the workon command in the `$PATH` variable. Suggest you to follow the similar answer [here](https://stackoverflow.com/a/25044349/4988681) – Arvind Nov 28 '19 at 19:57
  • I will greatly appreciate if you could help me with detailed screenshots. – HKS Nov 29 '19 at 05:50