I am new to Django 1.9.5, when trying the tutorial part 5 in the official website.
I followed their instructions and coded the tests.py file found here: https://docs.djangoproject.com/en/1.9/intro/tutorial05/
But when I run it, this is what I got:
ImportError: Failed to import test module: polls.tests
Traceback (most recent call last):
File "C:\Python27\lib\unittest\loader.py", line 254, in _find_tests
module = self._get_module_from_name(name)
File "C:\Python27\lib\unittest\loader.py", line 232, in _get_module_from_name__import__(name)
File "C:\Users\--\Desktop\Django\mysite\polls\tests.py", line 11, in <module>class QuestionMethodTests(TestCase):
File "C:\Users\--\Desktop\Django\mysite\polls\tests.py", line 20, in QuestionMethodTests
self.assertEqual(future_question.was_published_recently(), False)
NameError: name 'self' is not defined
Can any Django experts help me to understand the why is this happening and how do I solve it.
Thank you so much!
Related
I don't understand the syntax to call the render feature of ERAlchemy (https://pypi.org/project/ERAlchemy see "Usage for Python"). I am using Python 2.7, sqlite3, and PyCharm. I have ERAlchemy, GraphViz, and PyGraphViz installed.
I am trying the following, but it cannot connect to the database:
from eralchemy import render_er
render_er("sqlite:///C:\\Users\\myname\\Documents\\Work\\pythonsqlite.db", 'erd_from_sqlite.png')
And this is the error:
Traceback (most recent call last):
File "C:/Users/myname/Documents/Work/_sql_functions_rev0.py", line 81, in <module>
render_er("sqlite:///C:\\Users\\myname\\Documents\\Work\\pythonsqlite.db", 'erd_from_sqlite.png')
File "C:\Python27\ArcGISx6410.6\lib\site-packages\eralchemy\main.py", line 236, in render_er
intermediary_to_output(tables, relationships, output)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\eralchemy\main.py", line 75, in intermediary_to_schema
graph.draw(path=output, prog='dot', format=extension)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\pygraphviz\agraph.py", line 1474, in draw
data = self._run_prog(prog, args)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\pygraphviz\agraph.py", line 1308, in _run_prog
runprog = r'"%s"' % self._get_prog(prog)
File "C:\Python27\ArcGISx6410.6\lib\site-packages\pygraphviz\agraph.py", line 1295, in _get_prog
raise ValueError("Program %s not found in path." % prog)
ValueError: Program dot not found in path.
Ah! Found the answer here
had to find the folder with "dot.exe" and add it to the environment variables -> system variables -> path
I tried to find a solution for this problem but I didn't find anything.
======================================================================
ERROR: Failure: ImportError (No module named mock)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/nose/loader.py", line 390, in loadTestsFromName
addr.filename, addr.module)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 39, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/usr/lib/python2.7/dist-packages/nose/importer.py", line 86, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/home/ubuntu/client/tests/test_gs_interface.py", line 23, in <module>
import unittest, mock, kiss
ImportError: No module named mock
When I make a test with CIrcleCI using default parameters I always get the same ImportError.
I read at the documentation that I must set the configuration manually but I didn't find how to do.
Anybody could tell me how to import a module in the circle.xml configuration file?
Thank you.
Is mock included in your requirements.txt file? Also, do you have a Python version specified in your circle.yml file, as suggested here?
Any time i try scrapy crawl [name] I get the following error
Traceback (most recent call last):
File "/usr/local/bin/scrapy", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 576, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: Scrapy==0.24.5
I'm not sure what it is I'm missing, I've tried following suggestions from other similar questions but nothing is working! Any help would be appreciated.
Managed to figure it out. For some reason the pip install Scrapy was not completely installing so I downloaded the tarball from the website and then followed the instructions here and it now works!
I'm trying to intall the asterisk_click2dial module on ODOO and this error comes to me in the log file:
ValueError: Routing: posting a message without model should be with a parent_id (private mesage).
2015-03-09 15:23:38,262 11093 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/home/odoo/odoo/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/openerp/service/server.py", line 281, in app
return self.app(e, s)
File "/opt/odoo/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo/openerp/http.py", line 1274, in __call__
self.load_addons()
File "/opt/odoo/openerp/http.py", line 1293, in load_addons
m = __import__('openerp.addons.' + module)
File "/opt/odoo/openerp/modules/module.py", line 79, in load_module
mod = imp.load_module('openerp.addons.' + module_part, f, path, descr)
File "/opt/odoo/addons/base_phone/__init__.py", line 23, in <module>
from . import wizard
File "/opt/odoo/addons/base_phone/wizard/__init__.py", line 23, in <module>
from . import number_not_found
File "/opt/odoo/addons/base_phone/wizard/number_not_found.py", line 25, in <module>
import phonenumbers
ImportError: No module named phonenumbers
The problem is just that I installed that module (phonenumbers) plus the py-Asterisk module without errors using pip install phonenumbers and pip install py-Asterisk and the error persists.
I noticed I have at least two versions of python installed (2.6 and 2.7) but both modules are installed at the same version from odoo (I can see the modules in the python2.7 cli when, for example, I write phonenumbers or search).
Has anybody any idea what is happening to me? I'd be gratefull for some specific response. Thanks.
Here the connector's page: OpenERP - Asterisk connector
Ok, my bad. During odoo instalation I created a virtual environment under the Odoo system user account which was used solely by the Odoo server so I just need to install these modules under that enviorment. This works for me:
First let’s switch from root to the odoo user, then create a new virtual environment called odoo and activate it:
su - odoo
/usr/local/bin/virtualenv --python=/usr/local/bin/python2.7 odoo
source odoo/bin/activate
(If you have the virtual environment created like me just ignore the second line). Before starting the module installation we need to add the path to the PostgreSQL binaries, otherwise the PsycoPG2 module install will fail (I ignored this one too):
export PATH=/usr/pgsql-9.3/bin:$PATH
Then I can do pip install... Thank you all for your help.
I am trying to get the Django Shell working with the Google App Engine. Unfortunately, I am getting the following error:
AttributeError: type object 'RegistrationTestModel' has no attribute '_deferred'
Does anyone have any idea of how to fix this?
Stack trace:
WARNING:root:Could not read datastore data from /var/folders/X0/X0QgAfs7Hd8IcCVZOIkiCE+++TI/-Tmp-/django_content-sharer.datastore
WARNING:root:Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
Traceback (most recent call last):
File "manage.py", line 30, in <module>
execute_manager(settings)
File "/Users/chris/Documents/workspace/ContentSharer/src/__init__.py", line 362, in execute_manager
File "/Users/chris/Documents/workspace/ContentSharer/src/__init__.py", line 303, in execute
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/core/management/base.py", line 195, in run_from_argv
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/core/management/base.py", line 222, in execute
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/core/management/base.py", line 351, in handle
File "/Users/chris/Documents/workspace/ContentSharer/src/django/core/management/commands/shell.py", line 18, in handle_noargs
loaded_models = get_models()
File "/Users/chris/Documents/workspace/ContentSharer2/src/django/db/models/loading.py", line 166, in get_models
AttributeError: type object 'RegistrationTestModel' has no attribute '_deferred'
Are you using Django 1.1.2 with the helper? If so, the helper has not yet been updated for Django 1.1.2 yet. Be sure to get r105 or later of the helper. As a side note, Django 1.1.2 hasn't been installed on production for use_library yet, as far as I know.
Try using Django 1.1.1 until 1.1.2 is available on GAE production and the helper has been updated.
Patch is included in this ticket: http://code.google.com/p/google-app-engine-django/issues/detail?id=171
Update: the helper has been patched with r105 http://code.google.com/p/google-app-engine-django/source/detail?r=105
It looks like you're trying to load a part of Django that depends on Django models. Django models do not work on App Engine, as they depend on a relational database.
Try django-nonrel instead.