I am trying to setup travis-ci for the first time with a django project of mine and I am getting this trace in the travis output...
0.17s$ python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 13, in <module>
execute_from_command_line(sys.argv)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/core/management/__init__.py", line 316, in execute
settings.INSTALLED_APPS
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/opt/python/2.7.9/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named py
The command "python manage.py migrate" exited with 1.
Now I can see that it is looking for a module named py instead of running the manage.py file but I don't see why that would happen, and I have found numerous resources online that have stated to run a command like that in the travi.yml file (heres one: https://gist.github.com/ndarville/3625246)
here is my travis.yml file:
script:
- python manage.py migrate
- python manage.py test
Now before I go running off and trying to get it to run by installing another module like tox or nose I would like to know if it is possible to do it this why and why it is failing and where to find the info in the docs... Thanks
Related
I need to edit but first run this project: https://pagure.io/fedora-commops/fedora-happiness-packets and it gives me errors even though I followed the instructions.
First I forked the repo, then cloned it to my computer and I followed the instructions listed in the setup section of the README.md file. When I run the command ./manage.py collectstatic I get this error:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/alexmarginean/Desktop/fed/fedora-happiness-packets/virtualenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/alexmarginean/Desktop/fed/fedora-happiness-packets/virtualenv/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/Users/alexmarginean/Desktop/fed/fedora-happiness-packets/virtualenv/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/alexmarginean/Desktop/fed/fedora-happiness-packets/virtualenv/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/Users/alexmarginean/Desktop/fed/fedora-happiness-packets/virtualenv/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/alexmarginean/Desktop/fed/fedora-happiness-packets/happinesspackets/messaging/models.py", line 15, in <module>
from happinesspackets.tasks import send_html_mail
File "/Users/alexmarginean/Desktop/fed/fedora-happiness-packets/happinesspackets/tasks.py", line 3, in <module>
from happinesspackets._celery import app
File "/Users/alexmarginean/Desktop/fed/fedora-happiness-packets/happinesspackets/_celery.py", line 2, in <module>
from celery import Celery
ImportError: No module named celery
I tried importing celery but that method didn't work and I don't want to mess with the project.
Looking at issue 49, it looks like celery is a dependency but it isn not listed in the requirements. Until that is fixed, you'll have to install it manually.
pip install celery
Have you done pip install -r requirements in the virtualenv ?
When I try to run python manage.py runserver I get this error:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/core/management/__init__.py", line 307, in execute
settings.INSTALLED_APPS
File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/Users/user/lokvi/lokvi_env/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named settings
I have python 2.7 in my virtualenv. I noticed strange thing at the last lines of my stack trace, the line before the last line has path that goes like that: /lokvi_env/lib/python2.7 etc
But the last line goes like that System/Library/Frameworks etc, so it seems like path has changed from virtualenv to system. Is it ok?
You need to import settings module
from django.conf import settings
Oh, It was not the python path specific question, sorry. I just needed __init__.py in settings module inside of my project, since there were no settings it tried to find it in python lib itself and couldn't, I believe.
I would like to use Django to create an app but got an error
"ImportError: No module named books.apps" after running:
python manage.py startapp books
Error message:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/core/management/__init__.py", line 324, in execute
django.setup()
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Python/2.7/site-packages/Django-1.9-py2.7.egg/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named books.apps
Any idea what went wrong? Thanks!
You must first start a project before trying to start an app. First run:
python manage.py startproject mysite
and replace "mysite" with what you want to call your project. Then run:
python manage.py startapp books
See the docs here.
I'm writing this post because after hours of research around, no real solution was found about my issue.
I've a Django project that used to run on another computer. Now, I've a new one, I've reinstalled Django and VirtualEnvWrapper.
I've cloned my project from my git and I can work and deploy without any issues.
Running ./manage.py works when I'm on the correct virtualenv (via workon 'my_project_name').
My problem is that I can't generate translations any more.
Here is the trace-back:
(MyProject)--- python/MyProject ‹master*➔ M› »django-admin.py makemessages --all
Traceback (most recent call last):
File "/usr/local/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 376, in execute
sys.stdout.write(self.main_help_text() + '\n')
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 240, in main_help_text
for name, app in six.iteritems(get_commands()):
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'MyProject.settings.local' (Is it on sys.path? Is there an import error in the settings file?): No module named MyProject.settings.local
When I'm checking my sys.path, here is the content:
/Users/jbcollet/.virtualenvs/MyProject/lib/python27.zip
/Users/jbcollet/.virtualenvs/MyProject/lib/python2.7
/Users/jbcollet/.virtualenvs/MyProject/lib/python2.7/plat-darwin
/Users/jbcollet/.virtualenvs/MyProject/lib/python2.7/plat-mac
/Users/jbcollet/.virtualenvs/MyProject/lib/python2.7/plat-mac/lib-scriptpackages
/Users/jbcollet/.virtualenvs/MyProject/Extras/lib/python
/Users/jbcollet/.virtualenvs/MyProject/lib/python2.7/lib-tk
/Users/jbcollet/.virtualenvs/MyProject/lib/python2.7/lib-old
/Users/jbcollet/.virtualenvs/MyProject/lib/python2.7/lib-dynload
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages
/Users/jbcollet/.virtualenvs/MyProject/lib/python2.7/site-packages
Can someone help me with this?
Thanks a lot
I decided to try developing on python with django, while python is new to me right now.
[I'm using Windows 7 64bit]
Then, i installed python 2.7, added C:\Python27\;C:\Python27\Scripts; to PATH variable.
Next, i installed Eclipse Classic (last version) and installed PyDev, and Django.
I created my first project on Eclipse as a Django project but couldn't run it.
I'm trying (Right click on my project)-> Run as -> PyDev: Django, and i have the following console log:
Validating models...
Traceback (most recent call last): File "C:\Users\Matan\workspace\FirstSample\manage.py", line 10, in <module>
execute_from_command_line(sys.argv) File "C:\Python27\Lib\site-packages\django\core\management\__init__.py", line 443, in execute_from_command_line
utility.execute() File "C:\Python27\Lib\site-packages\django\core\management\__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python27\Lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__) File "C:\Python27\Lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options) File "C:\Python27\Lib\site-packages\django\core\management\commands\runserver.py", line 69, in handle
self.run(*args, **options) File "C:\Python27\Lib\site-packages\django\core\management\commands\runserver.py", line 80, in run
and the list goes on...
So i tried to run the project with the python console, using:
import Django
manage.py runserver
and i have the following syntax error:
File "<stdin>", line 1
manage.py runserver
^ SyntaxError: invalid syntax
What is the problem with running my project ? How can i solve this?
Thanks.
Edit:
After trying to run the project with the following command:
python manage.py runserver on the project directory, i receive the following traceback log: Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <dja ngo.contrib.staticfiles.management.commands.runserver.Command object at 0x000000 0002688748>> Traceback (most recent call last): File "C:\Python27\lib\site-packages\django\core\management\commands\runserver. py", line 91, in inner_run
self.validate(display_num_errors=True) File "C:\Python27\lib\site-packages\django\core\management\base.py", line 266, in validate
num_errors = get_validation_errors(s, app) File "C:\Python27\lib\site-packages\django\core\management\validation.py", lin e 23, in get_validation_errors
from django.db import models, connection File "C:\Python27\lib\site-packages\django\db\__init__.py", line 40, in <modul e>
backend = load_backend(connection.settings_dict['ENGINE']) File "C:\Python27\lib\site-packages\django\db\__init__.py", line 34, in
__geta ttr__
return getattr(connections[DEFAULT_DB_ALIAS], item) File "C:\Python27\lib\site-packages\django\db\utils.py", line 92, in
__getitem
__
backend = load_backend(db['ENGINE']) File "C:\Python27\lib\site-packages\django\db\utils.py", line 24, in load_back end
return import_module('.base', backend_name) File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im port_module
__import__(name) File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 16 , in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo dule named MySQLdb
Download the pre-compiled python-mysql package for Windows, install it, then run the command again.
While you are there, you might as well also install setuptools if you haven't already.
Error loading MySQLdb module: No mo dule named MySQLdb
You have configured your settings to you MySQL but you have not installed MySQL-python:
pip install MySQL-python
You must be in the project directory to run the python manage.py runserver command. You also need to (1) set the PYTHONPATH environment variable to include your project directory's parent and (2) set the DJANGO_SETTINGS_MODULE environment variable to yourproject.settings
If you've done it correctly, you should be able to go to an unrelated directory (i.e. not your project directory) and do the following import in a python shell:
c:\temp> python
...
>>> from django.conf import settings
the settings module that is imported should then be the one in your project directory...