pip install not working / responding - stuck until cancelled - python

When I try using pip install it freezes until I cancel the operation. I get the same with pip list.
I'm running on WSL Ubuntu 20.04 but I have no DNS issues. Tried with Google DNS, and WSL default, but didn't work.
Adding verbose -vvv does nothing different. Trying to upgrade pip gives the same behavior.
$ pip --version
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
$ python3 --version
Python 3.8.10
Traceback:
^CTraceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==20.0.2', 'console_scripts', 'pip')()
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/lib/python3/dist-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/usr/lib/python3/dist-packages/pip/_internal/cli/req_command.py", line 19, in <module>
from pip._internal.network.session import PipSession
File "/usr/lib/python3/dist-packages/pip/_internal/network/session.py", line 26, in <module>
from pip._internal.network.auth import MultiDomainBasicAuth
File "/usr/lib/python3/dist-packages/pip/_internal/network/auth.py", line 36, in <module>
import keyring # noqa
File "/usr/lib/python3/dist-packages/keyring/__init__.py", line 3, in <module>
from .core import (
File "/usr/lib/python3/dist-packages/keyring/core.py", line 189, in <module>
init_backend()
File "/usr/lib/python3/dist-packages/keyring/core.py", line 93, in init_backend
keyrings = filter(limit, backend.get_all_keyring())
File "/usr/lib/python3/dist-packages/keyring/util/__init__.py", line 21, in wrapper
func.always_returns = func(*args, **kwargs)
File "/usr/lib/python3/dist-packages/keyring/backend.py", line 210, in get_all_keyring
return list(rings)
File "/usr/lib/python3/dist-packages/keyring/util/__init__.py", line 31, in suppress_exceptions
for callable in callables:
File "/usr/lib/python3/dist-packages/keyring/util/properties.py", line 26, in __get__
return self.fget.__get__(None, owner)()
File "/usr/lib/python3/dist-packages/keyring/backend.py", line 67, in viable
cls.priority
File "/usr/lib/python3/dist-packages/keyring/util/properties.py", line 26, in __get__
return self.fget.__get__(None, owner)()
File "/usr/lib/python3/dist-packages/keyring/backends/kwallet.py", line 37, in priority
bus = dbus.SessionBus(mainloop=DBusGMainLoop())
File "/usr/lib/python3/dist-packages/dbus/_dbus.py", line 212, in __new__
return Bus.__new__(cls, Bus.TYPE_SESSION, private=private,
File "/usr/lib/python3/dist-packages/dbus/_dbus.py", line 102, in __new__
bus = BusConnection.__new__(subclass, bus_type, mainloop=mainloop)
File "/usr/lib/python3/dist-packages/dbus/bus.py", line 124, in __new__
bus = cls._new_for_bus(address_or_type, mainloop=mainloop)
File "/usr/lib/python3/dist-packages/dbus/exceptions.py", line 47, in __init__
def __init__(self, *args, **kwargs):
KeyboardInterrupt

This worked for me, as I had done some X11 setup recently:
unset DISPLAY
I have no idea how that could be related but it did the trick.
Source: https://github.com/pypa/pip/issues/7883#issuecomment-852102601

Related

Mac m1, rtree 0.9.7, spatialindex 1.9.3, symbol not found

() isikkaplan#iamhere# python3 manage.py loadfixtures -s=testing fixture fixtures/knock/0_ct.json -v3
Traceback (most recent call last):
File "/Users/isikkaplan/Desktop/code/---/-/--/manage.py", line 21, in <module>
main()
File "/Users/isikkaplan/Desktop/code/---/-/--/manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/alphashape/__init__.py", line 6, in <module>
from .alphashape import alphashape
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/alphashape/alphashape.py", line 15, in <module>
import geopandas
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/geopandas/__init__.py", line 1, in <module>
from geopandas._config import options # noqa
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/geopandas/_config.py", line 126, in <module>
default_value=_default_use_pygeos(),
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/geopandas/_config.py", line 112, in _default_use_pygeos
import geopandas._compat as compat
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/geopandas/_compat.py", line 202, in <module>
import rtree # noqa
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/rtree/__init__.py", line 9, in <module>
from .index import Rtree, Index # noqa
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/rtree/index.py", line 6, in <module>
from . import core
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/site-packages/rtree/core.py", line 77, in <module>
rt.Error_GetLastErrorNum.restype = ctypes.c_int
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/ctypes/__init__.py", line 395, in __getattr__
func = self.__getitem__(name)
File "/opt/homebrew/Caskroom/miniforge/base/envs/--/lib/python3.9/ctypes/__init__.py", line 400, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(RTLD_DEFAULT, Error_GetLastErrorNum): symbol not found
Almost all of the answers online leads to installing spatialindex which I already have and I have no idea how can I fix this.
If you are using a conda environment like I am, which is basically a necessity if you are on an m1 and not using docker, then you need to install the system libraries for the current environment via conda also.
conda install -c conda-forge libspatialindex

I'm facing some issues with pip version 20.1.1. Down below is the exact error I'm getting from pip

Here is the stacktrace I get from pip. I'm running Windows 10.
What to do here?
I can see the pip version and other options with main but can't download / install any packages.
D:\Python>python.exe -m pip install --upgrade pip
Traceback (most recent call last):
File "D:\Python\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\Python\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python\lib\site-packages\pip\__main__.py", line 26, in <module>
sys.exit(_main())
File "D:\Python\lib\site-packages\pip\_internal\cli\main.py", line 73, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "D:\Python\lib\site-packages\pip\_internal\commands\__init__.py", line 104, in create_command
module = importlib.import_module(module_path)
File "D:\Python\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\Python\lib\site-packages\pip\_internal\commands\install.py", line 24, in <module>
from pip._internal.cli.req_command import RequirementCommand, with_cleanup
File "D:\Python\lib\site-packages\pip\_internal\cli\req_command.py", line 16, in <module>
from pip._internal.index.package_finder import PackageFinder
File "D:\Python\lib\site-packages\pip\_internal\index\package_finder.py", line 21, in <module>
from pip._internal.index.collector import parse_links
File "D:\Python\lib\site-packages\pip\_internal\index\collector.py", line 14, in <module>
from pip._vendor import html5lib, requests
File "D:\Python\lib\site-packages\pip\_vendor\html5lib\__init__.py", line 25, in <module>
from .html5parser import HTMLParser, parse, parseFragment
File "D:\Python\lib\site-packages\pip\_vendor\html5lib\html5parser.py", line 7, in <module>
from . import _inputstream
File "D:\Python\lib\site-packages\pip\_vendor\html5lib\_inputstream.py", line 9, in <module>
from pip._vendor import webencodings
ImportError: cannot import name 'webencodings' from 'pip._vendor' (D:\Python\lib\site-packages\pip\_vendor\__init__.py)
This is due to broken build process just revert the pip version.
Try this:
$ pip install -U "pip<20" setuptools

Error while importing tensorflow after installing successfully

I am trying out tensorflow on my Mac. I use python 3.7 in a virtual environment.
I installed TensorFlow using pip install tensorflow successfully.
But now when I try to import it import tensorflow, it gives the following error
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/tensorflow/__init__.py", line 98, in <module>
from tensorflow_core import *
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/tensorflow_core/__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 959, in _find_and_load_unlocked
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/tensorflow/__init__.py", line 50, in __getattr__
module = self._load()
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/tensorflow/__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/tensorflow_core/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/tensorflow_core/core/framework/graph_pb2.py", line 7, in <module>
from google.protobuf import descriptor as _descriptor
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/google/protobuf/__init__.py", line 37, in <module>
__import__('pkg_resources').declare_namespace(__name__)
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/pkg_resources/__init__.py", line 84, in <module>
__import__('pkg_resources.extern.packaging.requirements')
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 9, in <module>
from pkg_resources.extern.pyparsing import stringStart, stringEnd, originalTextFor, ParseException
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/pkg_resources/extern/__init__.py", line 43, in load_module
__import__(extant)
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 4756, in <module>
_escapedPunc = Word( _bslash, r"\[]-*.$+^?()~ ", exact=2 ).setParseAction(lambda s,l,t:t[0][1])
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1284, in setParseAction
self.parseAction = list(map(_trim_arity, list(fns)))
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1066, in _trim_arity
this_line = extract_stack(limit=2)[-1]
File "/Users/sourabh/virtualenvs/ml/lib/python3.7/site-packages/pkg_resources/_vendor/pyparsing.py", line 1050, in extract_stack
frame_summary = traceback.extract_stack(limit=-offset+limit-1)[offset]
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/traceback.py", line 211, in extract_stack
stack = StackSummary.extract(walk_stack(f), limit=limit)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/traceback.py", line 363, in extract
f.line
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/traceback.py", line 285, in line
self._line = linecache.getline(self.filename, self.lineno).strip()
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/linecache.py", line 16, in getline
lines = getlines(filename, module_globals)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/linecache.py", line 48, in getlines
for mod in sys.modules.values():
RuntimeError: dictionary changed size during iteration
I've encountered the exact same problem, according https://github.com/tensorflow/tensorflow/issues/33183 this is an os-x catalina issue. However I found you can simply use python 3.7.6 to get rid of the problem, i.e. os-x catalina's python3 is version 3.7.3, with brew you can install python 3.7.6, backwards compatible and solves the problem :)

DLL load failed when running python manage.py runserver command

I'm getting DLL load failed when I try to run python manage.py runserver. It hapeens when I cd haddygirl and then run the previous command.
C:\Users\Lazxy\haddygirl>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Lazxy\Anaconda3\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\Lazxy\Anaconda3\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 54, in
wrapper
fn(*args, **kwargs)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\apps\config.py", line 211, in
import_models
self.models_module = import_module(models_module_name)
File "C:\Users\Lazxy\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\contrib\auth\models.py", line 2, in
<module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\contrib\auth\base_user.py", line 47, in
<module>
class AbstractBaseUser(models.Model):
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\models\base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\models\base.py", line 321, in
add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\models\options.py", line 204, in
contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Users\Lazxy\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\Lazxy\Anaconda3\lib\site-packages\django\db\backends\sqlite3\base.py", line 13,
in <module>
from sqlite3 import dbapi2 as Database
File "C:\Users\Lazxy\Anaconda3\lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "C:\Users\Lazxy\Anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
The error:
ImportError: DLL load failed: The specified module could not be found.
please help.
Seems that the driver for connect to sqlite are not found by the python installation.
Please share your python version. After Python 2.7.5 sqlite3 is shipped as a builtin dependencies.
Have a try with:
Use the builtin sqlite3
Install for python2
pip install pysqlite
Install for python3
pip install pysqlite3

Getting "django.core.exceptions.ImproperlyConfigured: GEOS is required and has not been detected." although GEOS is installed

I'm running Django 1.8 and Python 3.4 on Ubuntu 14.04 LTS. Just recently, my Django app has been reporting that GEOS is not present. GEOS is installed and libgeos_c.so is where it's supposed to be (/usr/lib/). My code seems fine. It is the source of a docker image which still works. This seems to indicate an os/incompatibility issue. Any help would be much appreciated.
The full traceback is
Traceback (most recent call last):
File "<path/to/my/homedir>/pycharm-4.5.1/helpers/pydev/pydevd.py", line 2358, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "<path/to/my/homedir>/pycharm-4.5.1/helpers/pydev/pydevd.py", line 1778, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "<path/to/my/homedir>/pycharm-4.5.1/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "<path/to/my/pycharm/project>/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1448, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/contrib/auth/models.py", line 41, in <module>
class Permission(models.Model):
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/db/models/base.py", line 139, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/db/models/base.py", line 324, in add_to_class
value.contribute_to_class(cls, name)
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/db/models/options.py", line 250, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/db/__init__.py", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/db/utils.py", line 240, in __getitem__
backend = load_backend(db['ENGINE'])
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/db/utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1448, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 8, in <module>
from .features import DatabaseFeatures
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/contrib/gis/db/backends/postgis/features.py", line 1, in <module>
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/contrib/gis/db/backends/base/features.py", line 3, in <module>
from django.contrib.gis.db.models import aggregates
File "<path/to/my/virtualenv>/lib/python3.4/site-packages/django/contrib/gis/db/models/__init__.py", line 12, in <module>
"See also https://docs.djangoproject.com/en/%s/ref/contrib/gis/install/geolibs/" % get_docs_version())
django.core.exceptions.ImproperlyConfigured: GEOS is required and has not been detected. Are you sure it is installed? See also https://docs.djangoproject.com/en/1.8/ref/contrib/gis/install/geolibs/
I've tried reinstalling libgdal-dev. All relevant packages (GDAL, GEOS etc) are up to date.
I've tried working my way back through the Python code. it fails in djanjo/contrib/gis/geos/__init__.py on the following. As HAS_GEOS is set to false it reports that GEOS is not present.
try:
from .libgeos import geos_version, geos_version_info # NOQA: flake8 detects only the last __all__
HAS_GEOS = True
__all__ += ['geos_version', 'geos_version_info']
except ImportError:
HAS_GEOS = False
I suspect that a recent OS upgrade/patch has broken GEOS or GDAL. The root cause seems to be something to do with ctypes, but I can't see what it could be.
The following might be useful.
>>> from _ctypes import Union, Structure, Array
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/<path/to/my/homedir>/pycharm-4.5.1/helpers/pydev/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: /usr/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so: undefined symbol: _PyTraceback_Add
>>> from django.contrib.gis import gdal
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/<path/to/my/homedir>/pycharm-4.5.1/helpers/pydev/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/<path/to/my/homedir>/pycharm-4.5.1/helpers/pydev/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/<path/to/my/virtualenv>/lib/python3.4/site-packages/django/contrib/gis/gdal/__init__.py", line 47, in <module>
from django.contrib.gis.gdal.driver import Driver # NOQA
File "/<path/to/my/homedir>/pycharm-4.5.1/helpers/pydev/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/<path/to/my/virtualenv>/lib/python3.4/site-packages/django/contrib/gis/gdal/driver.py", line 1, in <module>
from ctypes import c_void_p
File "/<path/to/my/homedir>/pycharm-4.5.1/helpers/pydev/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "/usr/lib/python3.4/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
File "/<path/to/my/homedir>/pycharm-4.5.1/helpers/pydev/pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: /usr/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so: undefined symbol: _PyTraceback_Add
I had the same problem today, though in an unrelated python project. This is is the line I also encountered and which led me here:
ImportError: /usr/lib/python3.4/lib-dynload/_ctypes.cpython-34m-x86_64-linux-gnu.so: undefined symbol: _PyTraceback_Add
It looks like Ubunut has pushed a Python 3.4 update which is not compatible with existing virtual environments. I'm able to fix the problem by recreating the virtualenv. Where this was impractical for the moment I simply replaced the virtualenv's python with the system one:
cd my-virtualenv
cp /usr/bin/python3.4 bin/python3.4
I can't say if this is a very sane thing to do, but it does seem to work in my case.
You should do
cp /usr/bin/python3 /path/to/my-virtualenv/bin/python3
instead, because that's the actual non-symlink file.

Categories