Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Daniel Luke
PLUS
Daniel Luke
Courses Plus Student 1,035 Points

Error Installing Django

Why do I get a syntax error when I run the command "pip install django" just like the Install Django video instructs us to do? I have Python installed.

Akash malhotra
Akash malhotra
3,025 Points

Check if your python comes with PIP, it should, but if not download pip. What OS are you using?

7 Answers

Daniel Luke
PLUS
Daniel Luke
Courses Plus Student 1,035 Points

I'm using Mac Yosemite. How do I check if Pip is installed with Python?

Akash malhotra
Akash malhotra
3,025 Points

1.sudo easy_install pip 2.sudo pip install Django 3.django-admin.py --version ( just to check version and see if it's installed properly)

Daniel Luke
PLUS
Daniel Luke
Courses Plus Student 1,035 Points

Akash,

Thank you so much! That seems to have actually worked. Now I have a new problem. I'm running this tutorial locally, or at least trying to, and when, following the tutorial to the letter, I try to get the server started by typing: python manage.py runserver 0.0.0.0:8000 I get error messages: No module named django.core.management, and the other one is: can't open manage.py

Akash malhotra
Akash malhotra
3,025 Points

try just doing python manage,py runserver. You don;t need the 0.0.0.0:8000.

Akash malhotra
Akash malhotra
3,025 Points

After you made the project by doing django-admin startproject mysite. Make sure you are in that directory, where ever you made that project. Then try : python manage.py migrate and then python manage.py runserver

Daniel Luke
PLUS
Daniel Luke
Courses Plus Student 1,035 Points

I keep getting the same error message when I run python manage.py migrate. I've run the command in the the same folder which has the manage.py file. The message is: "No module named django.core.management" Last night after following a video about installing python locally, there was something about setting up a virtual environment through venv. I figured that was gumming up the works, so I deleted the venv folder in Finder. Now I wonder if all this trouble has something to do with this. I looked into this folder before deleting it, and there were numerous versions of pip, and even Python itself. The reason I deleted it is to give myself a fresh start, but maybe I messed something up.

Akash malhotra
Akash malhotra
3,025 Points

Hmmm. Get the venv again, and activate it source /<virtualenv_path>/bin/activate SO now you should be inside your venv ( you will see that you're inside in your terminal)

Now try the whole process again and install django. I think that django isn't being recognized inside your venv.

Daniel Luke
PLUS
Daniel Luke
Courses Plus Student 1,035 Points

Akash,

I can't tell you how much I appreciate your help. I just yanked the venv file out of the trash and put it back where it was. That said, i don't know what you mean by "activate it source //bin/activate" I did enter that command into the command prompt at the home directory, and got yet another error. If I may gently suggest, pretend I'm a computer when providing instructions. Othewise I am sure to fail ; )

Akash malhotra
Akash malhotra
3,025 Points

Aha sorry man, I'm kinda new to this stuff too. Just trying to see what we can do!

k so let's start fresh. Remove that venv file, just delete it.

1.pip install virtualenv
2.cd (your project folder, wherever it is)
3.virtualenv venv1 ( We just created a new venv called "venv1", so we don't get confused with the previous deleted venv)
4.source venv1/bin/activate ( This is to enter the venv, make sure you see venv in terminal)
5.pip install -r requirements.txt ( This creates a file which contains a list of all the packages in the current environment, will be useful later)

  1. pip install django
  2. python manage.py migrate
  3. python manage.py runserver

Try all that and see if it works, all i can think off right now bro

Daniel Luke
PLUS
Daniel Luke
Courses Plus Student 1,035 Points

3rd step is not working. After I cd into learning_site (the folder where manage.py is) I typed virtualenv venv1 and received this error: --bash: virtualenv: command not found

Akash malhotra
Akash malhotra
3,025 Points

Not sure if same stuff works on Mac, I run windows. HMM, leave that whole folder and lets try making a new one. Just make a random folder on ur desktop, open up a new terminal, cd to it and try this:

1.sudo easy_install virtualenv
2.mkdir my_project
3.cd my_project
4.virtualenv venv
5.. venv/bin/activate
6.pip install django

Try seeing if my commands work for Mac, not sure

Akash malhotra
Akash malhotra
3,025 Points

IF that doesn't work, try following this vid man.
https://www.youtube.com/watch?v=FshRArXrEcM
I'm going to bed now, I'll try again tomorrow =p Sorry

Daniel Luke
PLUS
Daniel Luke
Courses Plus Student 1,035 Points

Thanks so much Akash. I really appreciate your efforts. All online tutorial sites are notoriously bad at helping students set up the proper environment. They skip over this part for some reason, but it's the most important part, because if you can't install and use the software, the lesson is useless.