I'm working in a Python 3.9 virtual environment on Ubuntu 20.04, and I'm getting an ImportError even though the package installed fine with pip.
The Setup:
Python:
3.9.7OS:
Ubuntu 20.04Package:
asyncpgVirtual Env:
venv
What I've Done:
Set up a clean venv:
-
python -m venv venv source venv/bin/activate Installed the package:
pip install asyncpgConfirmed the install:
pip listVerified the Python path:
which python # /path/to/venv/bin/python which pip # /path/to/venv/bin/pipPackage is present in
site-packages.
Error:
ImportError: cannot import name 'asyncpg' from 'asyncpg'Code:
import asyncpg async def fetch_data(): conn = await asyncpg.connect(user='user', password='password', database='db') return await conn.fetch('SELECT * FROM my_table')Question:
I can't figure out why it's not working. I’ve checked everything – no conflicting Python versions, package is installed, virtual environment is active. Anyone seen this before?
-