-
Notifications
You must be signed in to change notification settings - Fork 4
Unable to use the "django-admin.py startapp" command #16
Comments
Does it work if you set environment variables on the command line? PYTHONPATH=/vagrant/www DJANGO_SETTINGS_MODULE=settings django-admin.py startapp Also, does manage.py work? Without setting envs on the command line? |
I am finally able to create the app :), manage.py does not work without envs. (virtualenv)[vagrant@gcd-django-box www (example ✗)]$ manage.py |
I don't think manage.py is chmod'd to be directly executable- I always run "python manage.py ". Maybe it should be? I'll have to try building a new environment to see if I can reproduce this. I've never had the problem with manage.py, but never tried using django-admin.py so that's probably a day one setup bug. |
OK I brought up a new environment without doing any customization of settings. I was not able to run django-admin.py, but I am able to run manage.py just fine:
|
OK, the problem is that PYTHONPATH needs to be set to get django-admin.py to work:
I'm pretty sure that mange.py works because it is in the directory that needs to be in PYTHONPATH. I'll look into the right way to configure this in vagrant (or the stuff run by the Makefile). |
Reading up on PYTHONPATH and PYTHONHOME (because I can never remember the difference), we just want to set PYTHONPATH=/vagrant/www to allow any django-aware tool to work. I also verified that manage.py works because it is in that directory and is passed to the python executable as an argument. From the PYTHONPATH docs: "If a script argument is given, the directory containing the script is inserted in the path in front of $PYTHONPATH." It should be straightforward to get the vagrant environment to set this up. |
Hello,
I am trying to install the django rest framework and the first thing to do is to create an app. I run the command "django-admin.py startapp api" and here is the output I get:
(virtualenv)[vagrant@gcd-django-box www (example ✗)]$ django-admin.py startapp api
Traceback (most recent call last):
File "/opt/virtualenv/bin/django-admin.py", line 5, in management.execute_from_command_line()
File "/opt/virtualenv/local/lib/python2.7/site-packages/django/core/management/init.py", line 385, in execute_from_command_line utility.execute()
File "/opt/virtualenv/local/lib/python2.7/site-packages/django/core/management/init.py", line 345, in execute settings.INSTALLED_APPS
File "/opt/virtualenv/local/lib/python2.7/site-packages/django/conf/init.py", line 46, in getattr self._setup(name)
File "/opt/virtualenv/local/lib/python2.7/site-packages/django/conf/init.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/opt/virtualenv/local/lib/python2.7/site-packages/django/conf/init.py", line 98, in init % (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'settings' (Is it on sys.path? Is there an import error in the settings file?): No module named settings
I tried to follow this suggestion but it did not work.
I created a separate environment with Django 1.10 and ran the command django-admin.py startproject test and got the following results:
(env)[vagrant@gcd-django-box djangotest ]$ django-admin.py startproject test .
Traceback (most recent call last):
.....
File "/home/vagrant/djangotest/env/local/lib/python2.7/site-packages/django/conf/init.py", line 97, in init mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module import(name)
ImportError: No module named settings
Any suggestions greatly appreciated ;)
Thank you,
David
The text was updated successfully, but these errors were encountered: