Djangobb problem - python

I've installed Djangobb app on my server (Debian, mod_python) by cloning original source. The only things I've changed is database options in settings.py. All needed components are installed - syncdb query was executed right.
But, when I'm trying to enter on my forum, it returns me error:
ImproperlyConfigured: Error importing middleware django_authopenid.middleware: "No module named djangobb_forum.subscription"
I've checked - djangobb_forum/subscription.py exist, so I don't know what can be wrong.
Maybe someone had problems like that and know how to fix it?
Sorry for my english.

There are two obvious reasons to why this might happen:
djangobb_forum is not on your Python path
There is no __init__.py in the djangobb_forum folder
If the code says from djangobb_forum import ... then you need to have the parent folder of djangobb_forum on your Python path.

Related

Python Importing package at same level but different directory

python version:3.9.6
I cannot seem to get this to work I know there are a million posts that are the same as this but the solutions never seem to work for me. I've run into this before and always end up just restructuring the folders to include all files in one path which is obviously not ideal. So here I am once again asking you guys for help.
My folder structure is as follows
|project
|my_service
-my_service.py
|tests
- tests.py
I'm trying to get the function get_num_back from my_service.py and import it into tests.py.
I've tried relative imports from ..my_service.my_service import get_num_back this doesn't work because from what I've read I cannot hit the root folder.
I've then tried absolute import from my_service.my_service import get_num_back which is the answer I see works for everyone else but it doesn't seem to work for me. I've then tried from project import my_service as well as from project.my_service import my_service. as far as I understand with my python version I do not need __init__.py but I've also tried it with that as well.
the error
ModuleNotFoundError: No module named 'project'
Please settle this for me once and for all!
Always run py.test from your project directory.
Because from that directory it can actually find my_service.
For more information, read up on relative imports in the language reference documentation.

ModuleNotFoundError: No module named 'django_project.users'

** New user to SOF, sorry for poor post and thank you in advance for any help**
As the title says. I have been through multiple threads of StackOverflow with similar questions and none of them have given me a working solution.
My directories
The problem doesn't start until I add line18 into urls.py
and the error:
"ModuleNotFoundError: No module named django_project.users" is displayed.
I have tried different variations of importing the module and all seem to fail.
Traceback
I was following this tutorial:
https://www.youtube.com/watch?v=q4jPR-M0TAQ&t=753s
it wasn't until 14:00 where I was getting errors the author of the video was not. I have been following his tutorial from the beginning and have not run into any errors until now. I have been trying to find a solution for about 4 days now. Any help would be greatly appreciated.
I have pushed the most recent code to github and made the repository temporarily public for anyone who wants to replicate this problem:
https://github.com/ChristopherMillones/PyTest
EDIT: settings.py -> INSTALLED_APPS
django_project is your project root directory.
The apps inside are django_project, blog and users.
If you added those to your settings.py you have to import "stuff" from it like
from users.models import MyModel
In your project itself (django_project/django_project/*) you don't have a module users, that's why the error is thrown.

ImportError: No module named engine - Django suit related?

I am using Django and Django Suit V2 -
I am trying to create a custom home page for my django site using templates.
I keep getting this error: File "/usr/local/lib/python2.7/dist-packages/suit/apps.py", line 89, in add_suit_default_template_tags from django.template.engine import Engine
ImportError: No module named Engine
I want to make sure of what I'm doing before I go in and mess with the main files.
Anyone else deal with "No module named Engine" error before? Any Suggestions?
UPDATE - ok I corrected the first issue - I made sure the python interpreter was pointing to the virtualenv (it was already activated, so I deactivated and then reactivated). Was able to do a collectstatic with no error. I have now generated a different error which I will post in a different question since it's not directly related here. :)
It sounds like you have an old version of Django installed. The import
from django.template.engine import Engine
should work in Django 1.8+.

No module named django.core error

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.
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!

Python ImportError (Cannot import name Variables)

I have done some research on this question and nothing seems to fix it, I suspect I may be accidentally circularly importing somewhere, but this one has stumped me.
This package is a Python IRC Service framework. The issue occurs when dynamically loading a module (via imp.load_source()), and the new module tries to import something from the src folder (Variables.py). It fails with "Cannot import name Variables", yet, it imports another module from the same directory without complaint.
Here is the specific error:
**ERROR: ModLoad(): Unable to load module
/home/sam/workspace/Affinity/bin/../modules/ircd_affinity.py:
cannot import name Variables
**
This is the full file for modules/ircd_affinity.py: ircd_affinity.py, and src/Variables.py: Variables.py
If it helps. browse the entire repository... this (https://github.com/miniCruzer/Affinity/blob/master/src/Affinity.py) module (starting at line 123) loads modules.
I would appreciate if all responses were kept relevant to the specific issue at hand. Yes, it may be tempting to suggest other things I'm doing wrong or otherwise throughout the entire package - I am welcome to suggestions: please e-mail them to me.
Show the full traceback. Look through it for evidence of (attempted) circular import.
Run Python with the -v option ... what does that tell you?
Look at the contents of sys.path and sys.modules just before the error happens.
"**ERROR: ModLoad(): Unable to ..." doesn't look line a Python-raised error. Is that in your code? If so, dig deeper; why is it raised?

Categories

Resources