Search code examples
pythondjangoterminalkomodoedit

Terminal/django/komodo edit


I sincerely apologize for the noobish dribble thats about to come out here:

Okay so I am following along with a youtube tutorial using terminal/django/komodo edit to make a simple website. This is my first time really using terminal, I am having issues. I have read up on the terminal and searched this site for my question but to no avail. Im hoping someone will take the time to answer this for me as it is most infuriating. This is my first time working with virtual env's as well.

So my question is, How do I uhmm, I suppose "save" my virtual env settings? So I have set up a new virualenv. Downloaded django and started up my server so I can see things such as the admin page, log in page, from the internet page. Things go as they should along with the tutorial until it comes time to eventually turn off my computer.

When I reload the virtualenv I cannot run the server, it gives me: Import error, no module named django.core.management. I use pip freeze and it shows that django is no longer installed. If trying to reinstall django it gives a long block of error messages. All the work done within the virtualenv file is still visible for the komodo edit pages however, but it seems the terminal does not want to work properly. My only option thus far has been to completely remake a virualenv, re-set it all up with the proper imports, files, django and restart the project.

so my questions are: how do I save my terminal and/or virtualenv settings? What do I need to do before logging off to ensure I will be able to continue with my project? Lets say I am going to continue with my project, How do I start up the project again via terminal? Is that where I am going wrong? I've assumed up until now that I must go into terminal, start the server again and then from komodo edit continue with my project, but inside the terminal everything goes wrong.
Im not even explicitly saying I cannot continue with my project, I am more saying the terminal is not recognizing I had django installed within my virtualenv, and it is not letting me start the server again.

I have tried doing the research on my own, I am not one to sit back and wait for an answer but being completely new, this is baffling. I am sorry for the noob questions, feel free to link another answered question or website that has the answer.

Thank you all!!


Solution

  • Let's start from the beginning:

    1. You are in your project folder eg /home/me/myproject
    2. You create a new virtualenv, eg virtualenv /home/me/virtualenvs/myprojectenv
    3. You activate the new virtualenv:
      source /home/me/virtualenvs/myprojectenv/bin/activate
      ...this means that python and pip commands now point to the versions installed in your virtualenv
    4. You install your project dependencies pip install django
    5. You can ./manage.py runserver successfully

    Now, the virtualenv has only been activated in your current terminal session. If you cd outside your project directory the virtualenv is still active. But if you open a new terminal window (or turn off the computer and come back later) the virtualenv is not activated.

    If the virtualenv is not activated then the python and pip commands point to the system-installed copies (if they exist) and Django has not been installed there.

    All you need to do when you open a new terminal is step 3. above:

    source /home/me/virtualenvs/myprojectenv/bin/activate

    Possibly the tutorial you followed got you to install virtualenvwrapper which is an additional convenience layer around the virtualenv commands above. In that case the steps would look like this:

    1. You are in your project folder eg /home/me/myproject
    2. You create a new virtualenv, eg mkvirtualenv myprojectenv
      ...virtualenv has already been activated for you now!
    3. You install your project dependencies pip install django
    4. You can ./manage.py runserver successfully

    and whenever you start a new shell session you need to:

    workon myprojectenv

    in order to re-activate the virtualenv