Closed JakobMiksch closed 2 years ago
Guess this is with the Docker Image built for ARM? NameError: name 'basestring' is not defined
, strange, is referred as error when running Python2 code on Python3 or with certain Python 3 versions. I tried running the same command on an empty Docker system with the standard GHC geopython/geohealthcheck:latest
without a problem.
Using Alpine for Python has more issues (one is massive slower builds) at least it is harder to get right. Recent versions of Docker Ubuntu and Debian (-slim) images are small as well. You may want to try. In time we also want to migrate GHC Docker to Ubuntu or Debian.
I had this error on "normal" architecture on my laptop as well, but I could fix it by cleaning up my local Docker setup and re-downloading the GHC Docker image.
But I also have this problem on RaspberryPi with the base image arm32v7/python:3.7.9-alpine
Things I do not understand:
psycopg
- however, I do use SQLite and not PostgresI changed the context in the description to Raspberry Pi
Ok, I just found it this problem is not unique to Rpi. The latest GHC Docker Image running demo.geohealthcheck.org was just rebuilt (triggered by doc updates) and is now failing with similar error:
START /run-web.sh
Container timezone set to: Europe/London
START /configure.sh
Using DB_TYPE=postgresql
Check if Postgres is avail/ready...
ghc_demo_postgis:5432 - no response
Exit code=2 - Postgres not ready - sleeping
ghc_demo_postgis:5432 - accepting connections
Postgres is up - check if DB populated
count
-------
102
(1 row)
Postgres DB already populated
END /configure.sh
---> pavement.upgrade
Upgrading database...
cd /GeoHealthCheck/GeoHealthCheck
python manage.py db upgrade
2021-12-22 15:27:46,607 - init - INFO - created GHC App instance #1
Traceback (most recent call last):
File "manage.py", line 53, in <module>
manager.run()
File "/venv/lib/python3.7/site-packages/flask_script/__init__.py", line 417, in run
result = self.handle(argv[0], argv[1:])
File "/venv/lib/python3.7/site-packages/flask_script/__init__.py", line 386, in handle
res = handle(*args, **config)
File "/venv/lib/python3.7/site-packages/flask_script/commands.py", line 216, in __call__
return self.run(*args, **kwargs)
File "/venv/lib/python3.7/site-packages/flask_migrate/__init__.py", line 95, in wrapped
f(*args, **kwargs)
File "/venv/lib/python3.7/site-packages/flask_migrate/__init__.py", line 280, in upgrade
command.upgrade(config, revision, sql=sql, tag=tag)
File "/venv/lib/python3.7/site-packages/alembic/command.py", line 320, in upgrade
script.run_env()
File "/venv/lib/python3.7/site-packages/alembic/script/base.py", line 563, in run_env
util.load_python_file(self.dir, "env.py")
File "/venv/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 92, in load_python_file
module = load_module_py(module_id, path)
File "/venv/lib/python3.7/site-packages/alembic/util/pyfiles.py", line 108, in load_module_py
spec.loader.exec_module(module) # type: ignore
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "migrations/env.py", line 87, in <module>
run_migrations_online()
File "migrations/env.py", line 70, in run_migrations_online
poolclass=pool.NullPool)
File "/venv/lib/python3.7/site-packages/sqlalchemy/engine/__init__.py", line 499, in engine_from_config
return create_engine(url, **options)
File "/venv/lib/python3.7/site-packages/sqlalchemy/engine/__init__.py", line 456, in create_engine
return strategy.create(*args, **kwargs)
File "/venv/lib/python3.7/site-packages/sqlalchemy/engine/strategies.py", line 87, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/venv/lib/python3.7/site-packages/sqlalchemy/dialects/postgresql/psycopg2.py", line 737, in dbapi
import psycopg2
File "/venv/lib/python3.7/site-packages/psycopg2/__init__.py", line 68, in <module>
from psycopg2 import extensions as _ext
File "/venv/lib/python3.7/site-packages/psycopg2/extensions.py", line 211, in <module>
from psycopg2. _range import Range # noqa
File "/venv/lib/python3.7/site-packages/psycopg2/_range.py", line 502, in <module>
oid=3904, subtype_oid=23, array_oid=3905)
File "/venv/lib/python3.7/site-packages/psycopg2/_range.py", line 283, in __init__
self._create_ranges(pgrange, pyrange)
File "/venv/lib/python3.7/site-packages/psycopg2/_range.py", line 302, in _create_ranges
if isinstance(pgrange, basestring):
NameError: name 'basestring' is not defined
The failing build is not due to the changes, there is a problem in a unit test involving ArcGIS server...
So the fix, upgrading to psycopg2
2.9.2 works! @JakobMiksch : this may also now work for Docker on Raspberry Pi.
Describe the bug
Starting GHC with docker-compose fails with error
name 'basestring' is not defined
To Reproduce
./docker/compose
docker-compose -f docker-compose.yml up
Expected Behavior GHC should run without errors.
Screenshots or Logfiles
Context (please complete the following information):