How to install Django in a virtual environment?

0

I'm having problems with a Django installation that I did in a virtual environment and basically I have only one question:

Is it necessary to install Django within each new virtual environment that I create? that is, if I create a new Django project in a virtual environment, do I have to always install it again?

What happens is that a while ago I did a virtualenv and installed Django on it. Then I deleted it and now I created another and reinstalled the framework inside but I get this error and I do not know how to fix it:

It does not allow me to run django-admin.py, only when I put the word Python first, but still it does not allow me to execute new projects ... I do not know what to do! : (

Thank you all.

    
asked by Old Wolf 12.11.2016 в 19:50
source

2 answers

1

Indeed, each virtualenv is an isolated environment in which you must install the necessary packages to run your project. I recommend you generate a file with the requirements (if you do not have it) and execute it, with that your problem should be solved.

... and do not forget that each virtualenv is a separate environment where you can carry different projects.

    
answered by 13.11.2016 в 04:38
0

I recommend using Linux instead of windows to work with Django and the virtualenvs, because with it is easier to update to new versions of both with simple commands, while Windows is complicated when you have to download installers for all . Apparently your problem occurs because you have not activated your virtual environment, so you can not find the installed Django tools to use them.

In linux you can do the following.

Instalás Virtualenv, and once done that:

  • You activate your virtualenv with source tuVirtualenv/bin/activate .
  • Instalás Django with pip install django
  • You create your project with django-admin.py startproject tuProyecto
  • You enter the project folder and you can work with Django quietly.
  • To deactivate the virtualenv to change to another or for any other reason you can do it by running the deactivate command. Every time you want to work with your project, do not forget to activate your virtualenv with source tuVirtualenv/bin/activate .

    I hope I helped you. Greetings

        
    answered by 15.11.2016 в 00:50