5đź‘Ť
I was able to get rid of the import errors executing this cmd
sudo ln -s /usr/lib/pymodules/ /usr/lib/python2.6/pymodules
I was lucky, testing different things I could resolve it but I’m not sure why I have to do this and how I could avoid doing it.
16đź‘Ť
Check your pythonpath. You need to include the parent directory of django, usually Lib/site-packages.
- Django Tutorial: name 'HttpResponse' is not defined
- Django aggregation: sum then average
- 'WSGIRequest' object has no attribute 'get'
6đź‘Ť
I’m on Mac OS X, but all I had to do was to add:
/Library/Python/2.6/site-packages
to my System PYTHONPATH (Found in: Preferences > Pydev > Interpreter – Python)
The equivalent for Ubuntu 10.04 would be:
/usr/lib/pymodules/python2.6
I’m guessing that the equivalent for Ubuntu 9.x could be:
/usr/lib/python2.6/site-packages
If it isn’t and you’re tired of looking, just upgrade to Ubuntu 10.04 and you should be fine.
- Django attribute error. 'module' object has no attribute 'rindex'
- How to write a Django view for a POST request
- How to get the submitted value of a form in a Django class-based view?
- Django Serialize Queryset to JSON to construct RESTful response with only field information and id
- Why django uses a comma as decimal separator
3đź‘Ť
“Unresolved imports” occur when Eclipse/Pydev does not know what you want to import. Check your Pydev settings in the Eclipse preferences > Interpreter Python. Your site-packages folder and things you want to import should be there in the Pythonpath.
- Django ALLOWED_HOSTS with ELB HealthCheck
- How to output text from database with line breaks in a django template?
- Testing a custom Django template filter
3đź‘Ť
Even if Lib/site-packages is added to the PYTHONPATH, this problem may happen when using modules from egg packages installed using easy_install. The problem with those, and that might actually depend on the easy_install version, is that by default they don’t get installed directly inside Lib/site-packages but rather under a folder containing the full package name and having the .egg suffix. For example: Lib/site-packages/django_celery-3.0.23-py2.7.egg
Each module coming from packages installed as above needs an individual entry in PYTHONPATH. If the packages are installed after PyDev has been installed on the system, the system PYTHONPATH needs to be updated in PyDev. That is done automatically by going to Window -> Preferences -> PyDev -> Select your intepreter -> in the python interpreters panel remove and re-add your current python interpreter (usually, this should be the python executable from the system). Then a PyDev restart (File -> Restart) should solve the “Unresolved import” errors.
- Django, register user with first name and last name?
- Python venv not creating virtual environment
- Django Bi-directional ManyToMany – How to prevent table creation on second model?
- How to use Datepicker in django
- Can you declare multiple with variables in a django template?
2đź‘Ť
If you are facing problem of unused imports then I must say use Eclipse as a IDE as it is providing functionality to remove unused imports by pressing keys ctr+shift+O. Or In Eclipse there is plugin also available which is doing the same thing automatically when you save your code.You can get that plugin from eclipse plugin site easily and free of cost.
- {% load static %} and {% load staticfiles %}: which is preferred?
- How can I create a case-insensitive database index in Django?
- GeoDjango on Windows: Try setting GDAL_LIBRARY_PATH in your settings
2đź‘Ť
In my case of the modules were dependent on setuptools-14.3.1 , which was causing all these problems. After installation of setuptools-14.3.1 rest of the modules automatically resolved.
- What is the best IDE setup for web development?
- Installing django 1.5(development version) in virtualenv
- Convert python datetime with timezone to string
1đź‘Ť
I was having a single import error when working in PyDEV in eclipse.
I was importing it like
from xyz_module import abc
So I clicked “Ctl + 1” and “select Unresolved import error” in eclipse and it created a class
file in a python file.
It turned out that I had created an application called “xyz_module” and a “xyz_module.py” file (with the same name that is) and this was causing an import error. I changed the python file to a new name and this resolved the error.
- Yuglify compressor can't find binary from package installed through npm
- Django AttributeError: 'DatabaseOperations' object has no attribute 'select'
- Why am I unable to run django migrations via the 'docker-compose run web' command?
- Multiple USERNAME_FIELD in django user model
- How to remove the language identifier from django-cms 2.4 URLs?
1đź‘Ť
I had the same error and none of the answers worked for me as there was no PYTHONPATH options under Window -> Preferences -> PyDev -> Python.
Instead I added PYTHONPATH setting in the menu:
Project -> PyDev-PYTHONPATH -> External Libraries -> Add Source folder
I added the path of site-packages like
/home/Documents/hcx/venv/lib/python3.5/site-packages
Now PyDev stopped complaining.