3

EDIT #2: Solved! 7 hours spent because of a default read-only permission. See answer below!

Windows 8 machine, Django 1.6.5, Python 2.7.8

So I set Django up earlier on a VPN (trying to learn to code from China is tough) and everything worked well. However, this time I tried it, I got this error:

ImportError: No module named django.core

Here's a picture of it in full:

Here's what I've done so far after looking at other StackOverflow threads -

  • Checked to make sure there is only one version of Python (2.7.8)
  • Made sure I activated the virtualenv (you can see it in the image above)
  • Un/reinstalled python anyways
  • Reinstalled django in this virtualen
  • Set up a different virtualenv to no avail
  • Recreated virtualenv from scratch
  • Double checked my environmental variable PATH was set to:
C:\Windows\System32;C:\Python27;C:\Python27\python.exe;C:\Python27\Scripts\;C:\Python27\Lib\site-packages\django\bin;

(this is because I'm following this tutorial: http://codingforentrepreneurs.com/projects/launch-with-code/start-project/)

  • Removed #!/usr/bin/env python from both manage.py; didn't work, so put it back in

EDIT: - Turned off "Read-only" permissions of Lib\site-packages\django where the django-admin.py file is located

Should have searched on stackoverflow instead of Bing/Google. Found a few other related questions/answers but am confused about: - $PYTHONPATH, my video guide doesn't mention this at all so I have no idea where to start (https://stackoverflow.com/a/6059969/4194756 and http://blog.jayteebee.org/2009/07/importerror-no-module-named-djangocore.html) - When I tried this way to use the "correct" python,

ftype Python.File="E:\Python27\YOUR_ENVIRONMENT\Scripts\python.exe" "%1" %*

It gave me an error message:

Access is denied. Error occurred while processing: Python.File

I've still got a problem though as you can see in the image.

Community
  • 1
  • 1
Ashley
  • 63
  • 9
  • 2
    Your error message is text. Why are you showing us a picture of text? Copy and paste the error here. – Andy Oct 29 '14 at 15:45
  • Didn't know I could C/P from command prompt (as I said, I'm new to this). Will take a look but it's midnight here and the coffee shop I'm in is about to close - will copy a response in the morning – Ashley Oct 29 '14 at 15:49
  • Have you tried `python django-admin.py startproject lec`? – rnevius Oct 29 '14 at 15:50
  • 1
    This could also be a permissions error. Unfortunately when Python's module system tries to import from a directory that it doesn't have read permissions to, it treats it as if it doesn't exist, rather than telling you it couldn't access the folder. I know I've had this problem *many* times with `pip` on systems that have complicated per-user permissions that `pip` doesn't always correctly apply. – aruisdante Oct 29 '14 at 15:51
  • Also, what do you get if you do a `which python`? – rnevius Oct 29 '14 at 15:52
  • @rnevius: I tried, and got: python: can't open file 'django-admin.py': [Errno 2] No such file or directory However, I'm currently in \Downloads\lwc, there is a file called django-admin.py in \lwc\Scripts – Ashley Oct 29 '14 at 16:00
  • @rnevius: 'which python' returns a 'which' is not recognized as an internal or external command, operable program or batch file. also good news i can access wifi from outside the coffeeshop. – Ashley Oct 29 '14 at 16:03
  • here's an image if that helps: http://i.imgur.com/uxZPoWp.png – Ashley Oct 29 '14 at 16:06
  • Ick...sorry to say, I have no idea what's going on. This is one of the many reasons we end up installing ubuntu (or similar) as a virtual machine and develop that way. I'm using Windows, but after hours and hours of painful struggle, trying to get Django to work...I just whipped up a Xubuntu VirtualBox environment, and develop from there. Always an option. – rnevius Oct 29 '14 at 16:27
  • No worries. I emailed the guy who runs the site and hopefully he'll have an answer. I've got an excuse to eat KFC in China now (wifi is scarce here) so that's a plus – Ashley Oct 29 '14 at 16:57
  • @Patrick, which is a shell command so it won't come up if you are using windows. You might have more luck with `pip show` when it comes to getting information about packages https://pip.readthedocs.org/en/latest/reference/pip_show.html. Generally speaking it's a good idea to set up a virtualenv for your project before you get started, that way you can install the packages related to the project into the virtualenv. – shuttle87 Oct 29 '14 at 17:18
  • @shuttle87, that's what I did. virtualenv lwc --> this made the folder and related files. I then installed django, etc. Or am I misunderstanding your comment? – Ashley Oct 29 '14 at 17:47

1 Answers1

1

Found a link here: http://samudranb.com/2012/06/02/how-to-setup-a-djangopython-development-env-on-windows/

Check the folder permissions of the “django” folder inside “YOUR_ENVIRONMENT\Lib\site-packages“. Remove any read-only permission settings.

There was a default read-only permissions setting on the folder mentioned and after disabling it, everything's working again! Woo time to get out of a sketchy KFC and get some sleep. Thanks everyone!

Also, shout out to @aruisdante who mentioned in the comments that it could be a permissions error. Didn't know where to go from there being inexperienced but glad it worked out!

Ashley
  • 63
  • 9
  • Glad you figured it out. Sorry I didn't offer more help, I'm not super familiar with the permissions system on Windows. If it was Linux I would have immediately recommended a `sudo chmod a+x+r -R` on the django folder :p – aruisdante Oct 29 '14 at 19:46