I cannot import GeoIP in django. I searched and tested this error two days, but still could not know problem.
Surely, I installed GeoDjango. I'm on MacOS 10.8
following is log by tested by django shell
from django.contrib.gis import geoip
module 'django.contrib.gis.geoip' from '/Library/Python/2.7/site-packages/django/contrib/gis/geoip/__init__.pyc'
it works. even I could find geoip class at Library/Python/2.7/site-packages/django/contrib/gis/geoip/base.py
from django.contrib.gis.geoip import geoip
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name geoip
I also add django.contrib.gis to setting.py. Even I could find geoip class at eclipse shortcut.
anyway, I tested one more thing in django shell.
from django.contrib.gis.geoip.base import GeoIP
Traceback (most recent call last):
File "", line 1, in
File "/Library/Python/2.7/site-packages/django/contrib/gis/geoip/base.py", line 6, in
from django.contrib.gis.geoip.libgeoip import GEOIP_SETTINGS
File "/Library/Python/2.7/site-packages/django/contrib/gis/geoip/libgeoip.py", line 22, in
if lib_path is None: raise GeoIPException('Could not find the GeoIP library (tried "%s"). '
NameError: name 'GeoIPException' is not defined
What I missing?
Is there any way to test my error?
It appears you need to install a C library in order to use GeoIP.
Here is a snippet from the file that is throwing that error.
# The shared library for the GeoIP C API. May be downloaded
# from http://www.maxmind.com/download/geoip/api/c/
if lib_path:
lib_name = None
else:
# TODO: Is this really the library name for Windows?
lib_name = 'GeoIP'
Once you have it installed somewhere you need to reference it in your settings.py
GEOIP_LIBRARY_PATH = '/whatever'
The library was trying to tell you this, but it seems that there is a bug that prevents it from raising the correct error. https://github.com/django/django/pull/103
Previously i was facing this issue : from django.contrib.gis.geoip import GeoIP ImportError: cannot import name GeoIP
which is solved when i install this package.
yum install GeoIP-devel -y
The error is caused by moving the virtual environment folder.
The solution is to create the environment again and reinstall the pygeoip library.
Related
I need help with the pyodbc Python module. I installed it via Canopy package management, but when I try to import it, I get an error (no module named pyodbc). Why?
Here's the output from my Python interpreter:
import pyodbc
Traceback (most recent call last):
File "", line 1, in
import pyodbc
ImportError: No module named 'pyodbc
For the record: the attempted import was in a different Python installation. It is never good, and usually impossible, to use a package which was installed into one Python installation, in another Python installation.
$ python3 setup-py install
....
Installed /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/twitter-1.17.1-py3.5.egg
Processing dependencies for twitter==1.17.1
Finished processing dependencies for twitter==1.17.1
$ python3 twitter.py
Traceback (most recent call last):
File "twitter.py", line 1, in <module>
from twitter import Twitter
File "/Users/eddiee/2_python/twitter.py", line 1, in <module>
from twitter import Twitter
ImportError: cannot import name 'Twitter'
What might cause the problem:
Due to the restrictions of the preinstalled python on Mac, I installed another new python and changed the path. But I don't know how to install the module to the new python.
Eddie:
Try to change the import line to:
import twitter
or:
from twitter import Twitter
Hope it helps.
The problem here is I names my file as "twitter.py". When I imported the twitter module, python automatically imported the file itself, because the current file has a higher priority over the module. Simply changing the file name can solve the problem.
I am trying to configure svn hook for email notification using mailer.py script from apache, but it always crash on import of svn libs. I try two ways of installing svn and python. I try to install everything manually using command line and use CollableNet installer that have preinstalled Python and all libs I need but result is the same.
Now I try to import one library from hole package that I need using python in command line and I have such response:
>>> import svn.core
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named svn.core
I try to fix it using:
1) import sys; sys.path.append("C:\csvn\lib\svn-python\svn")
and
2) C:\csvn\lib\svn-python\svn>python "\__init__.py" install
But it didn't help.
For now I have no package with setup.py to install it.
I spend a lot of time on this task, and going crazy a little). Please give me any suggestion how to fix it.
I'm trying to use MySQLdb and when I try to import it I get the following error. Any thoughts? I'm currently using an ubuntu instance on aws.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory
>>>
Is libmysqlclient-dev installed? Package might not be exact, but thats the general idea.
Is this comment thread of any help?
Try updating /etc/ld.so.conf so as to include the directory in which you've installed this.
After struggling with this same issue myself (on the AWS Linux I AMI), I found the answer
here:
While the comment thread already posted was helpful, Apache was clearing my environment variables, so setting LD_RUN_PATH and/or LD_LIBRARY_PATH was not effective.
What ended up working was adding a new include statement to /etc/ld.so.conf and running ldconfig.
I installed flask by the instructions on the page
http://flask.pocoo.org/docs/installation/#installation
Now, when I try
>>> import os
>>> from flask import Flask
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named flask
This means that os can be found whereas Flask cannot. How could you tell to python, where to find the needed modules?
Flask depends on two external libraries, Werkzeug and Jinja2.
you can check in your Lib\site-packages dir in windows or site-packages in other os whether you had installed it successfully
I think you should try to install it again.
it has no matter with the os module