ImportError: cannot import name 'APIClient' / running problem on python 3.6
See original GitHub issueHi,
I was trying to use the test containers with django in order to set-up postgres db for tests. Unfortunately when I try to setup db according the documentation:
postgres_container = PostgresContainer("postgres:9.5")
with postgres_container as postgres:
e = sqlalchemy.create_engine(postgres.get_connection_url())
result = e.execute("select version()")
I receive the following error:
File ".virtualenv/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "settings.py", line 14, in <module>
from testcontainers import PostgresContainer
File ".virtualenv/lib/python3.6/site-packages/testcontainers/__init__.py", line 1, in <module>
from testcontainers.selenium import BrowserWebDriverContainer
File ".virtualenv/lib/python3.6/site-packages/testcontainers/selenium.py", line 16, in <module>
from testcontainers.core.container import DockerContainer
File ".virtualenv/lib/python3.6/site-packages/testcontainers/core/container.py", line 3, in <module>
from docker.models.containers import Container
File ".virtualenv/lib/python3.6/site-packages/docker/models/containers.py", line 3, in <module>
from ..api import APIClient
ImportError: cannot import name 'APIClient'
I’m using Python 3.6.3 and testcontainers 2.1.0. Do you know what could make a problem?
Thx
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
ImportError: cannot import name discovery - Stack Overflow
If you cannot import discovery from apiclient, then try: from googleapiclient import ... sudo pip install --upgrade google-api-python-client.
Read more >[Fixed] ModuleNotFoundError: No module named 'google'
Quick Fix: Python raises the ImportError: No module named 'googleapiclient' when it cannot find the library google-api-python-client .
Read more >[Example code]-Cannot import `google` in Python code
I'm trying to follow the code from here: https://developers.google.com/api-client-library/python/auth/web-app but I can't figure out what library I need to ...
Read more >Napari: Cannot import name '_AnnotatedAlias' - Usage & Issues
When I run import napari, I get the following error. ... Usage & Issues ... but it looks like you have a python...
Read more >ImportError cannot import nameApiClient - IoT Devices - Ubidots
but i have import error cannot import name ApiClient when i run it. But i tried with the issue of the version of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hm. need to look at it
@pnowy, you say I was trying to use the test containers with django in order to set-up postgres db for tests, however, your code example uses SQLAlchemy:
sqlalchemy.create_engine(postgres.get_connection_url())
.Did you get testcontainters-python working with Django and can you describe how? Getting Django settings configured properly with testcontainters-python seems quite tricky to me.