django views - unresolved import - python

I have installed the cloudinary image CDN service with easy_install and put cloudinary into my settings.py as app, did syncdb --migrate. To this point everything is fine.
But once I want to use it in views.py:
import cloudinary
...it is showing the error, unresolved import: cloudinary
What can be the reason for this? I thought easy_install solves all path related issues while installing. Does it not?

For those who may encounter this issue, the solution that worked for me is:
go to Preferences / PyDev / Interpreter - Python
and remove the Interpreter and do autoconfig again. then it will find the modules and import them

Related

Django error: unresolved import 'extra_views'

I'm trying to use extra_view Django package. I've installed it and in terminal it showed as successful and I added it to installed apps in setting.py. As I don't use virtual environment it's all installed globally, but when I try to import that package there is an unresolved import error. I use VS Code if it means something. It also happened with some other packages that I installed. Do you have any idea what is happening?
Can you show full traceback to this error?
And your code where you import it.
It should work fine if you do everything as it says here in the docs:
https://django-extra-views.readthedocs.io/en/latest/pages/getting-started.html
Everything is ok actually. I just restarted VS Code and then there weren't any errors anymore. Apparently VS Code was the only issue.

Python imports suddenly failing

I had a few imports I was using for my project. Some of these included packages I downloaded using pip like
import MySQLdb
While others were modules from within my project like
sys.path.append(os.path.join(os.path.dirname(__file__), "../")) .
from util.myFile import get_mysql_connection, execute_query,
These were all working and I was able to run my application on PyCharm. I closed PyCharm and opened it back up to find most of these imports "could not be found". Any help regarding this will be much appreciated. Thanks
Update:
I'm able to run the file from terminal (iTerm) without errors. However, the file still shows red error marks by the imports. Seems like PyCharm isn't recognizing some sort of path
Check the traceback for what version of python is being called.
There could be a mismatch between the version you've imported modules with and the version that runs by default.
Double check what is being used as your project interpreter. This can change the available packages to your current project.
Found in PyCharm by going to Settings -> Project:<'Your-Project'> -> Project Interpreter
Also, did you install MySQLdb in this way? MySQLdb - ModuleNotFoundError

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

Django library Unresolved Import LiClipse

I am creating my first Django project from docs.djangoproject.com. After completing tutorial 4, I tried to import my project in LiClipse. But LiClipse is showing error of Unresolved Import however my projects works perfectly fine.
I have added django in external library.
Please help me with this issue.
LiClipse shows error only with django libraries and not with any other python library
Instead of adding django package as external library, add the containing folder of django. For example if folder hierarchy is something like /site-package/django than add site-package as external library and not django.

Error importing simplejson and antlr3 to djangoappengine project

I'm building a project that uses django-app-engine, but get some import errors when running the project with the GAE launcher.
My first error is importing simplejson, same as: Error importing simplejson after upgrading to appengine dev server 1.7.6
I've resolved that issue by modifying old_dev_appserver.py in the GAE bundle to import 'json' instead of 'simplejson' (I hope it's ok that I modified the GAE bundle..)
After the change, I receive a new error:
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/cron/groc.py", line 31, in <module>
import antlr3
ImportError: No module named antlr3
In the link above, #trope actually commented on having the same issue, but I thought a new question would be better than adding comments to the original issue (which is resolved by changing simplejson to json)
As suggested here: Django App Engine can't find antlr3 module, I've tried to add
os.path.join(SDK_PATH, 'lib', 'antlr3')
And also tried to install the antlr3 runtime.
I feel this issue is different to the one above because it's a direct result of the simplejson workaround, but perhaps it is the same.
Python 2.7.2, GAELauncher 1.9.4
Any suggestions?
edit: I've also now tried the exact same setup/codebase on my PC with the latest version of Launcher, and I get the exact same two errors: first simplejson, then antlr3. Maybe that means it's an issue with the codebase/djangoappengine install?
OK, this should be solved. Make sure you have updated all the django nonrel projects (dbindexer, django, djangoappengine, djangotoolbox, and whatever else you use). Also, run gcloud components update from the command line.
In addition to adding os.path.join(SDK_PATH, 'lib', 'antlr3'), did you also actually download and install it? From the command line, run whereis antlr3.

Categories

Resources