I'm using in my lambda SQLAlchemy
I'm using python 3.8 (It supposed to work also in 3.7 to I don't care to change)
I downloaded the module separately and uploaded it as a zip with my code.
It looks like this:
But I'm still getting this error:
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'sqlalchemy'
Any idea why? How can I solve it? Unfortunately, I must use sqlalchemy so I can't change the module
Edit:
This is how I import:
from sqlalchemy import and_
from sqlalchemy.sql.functions import count
But I also tried with package.sqlalchemy and got the same results
Related
I'm using a Python library (pyPyrTools), which is giving me an import error.
../../../venv/lib/python3.8/site-packages/pyPyrTools/__init__.py:1: in <module>
from binomialFilter import binomialFilter
E ModuleNotFoundError: No module named 'binomialFilter'
Inspecting the module in venv/lib/site-packages, I find the following structure:
-pyPyrTools
---__init__.py
---binomialFilter.py
And inspecting __init__.py, it's a pretty standard fare import:
from binomialFilter import binomialFilter
binomialFilter.py does include a function called binomialFilter.
Any idea why I'm getting this error from this library? There aren't any relative imports or anything funky, and the files all exist on the right level. It all looks correct to me.
The module looks like it was written for 2.7, and I'm using 3.8 if that is relevant.
When I'm trying to import rasterio in AWS Lambda I receive the following error:
Unable to import module 'lambda_function': No module named 'rasterio._base'
At first, I received the following error:
Unable to import module 'lambda_function': No module named 'rasterio'
So I tried to pip install the module, compressed it into a zip, and upload it as a layer(I did the same for the requests module and it worked just fine),
but now I'm getting:
Unable to import module 'lambda_function': No module named 'rasterio._base'
I've also tried:
Creating an empty virtual environment -> pip installing rasterio ->
compressing the module.
Installing different versions of rasterio
When I try to import rasterio._base through the CLI it works, but for some reason it fails to compile in the lambda.
Any suggestions?
use rasterio-lambda-layer - see https://github.com/addresscloud/rasterio-lambda-layer
I try to import class ClickHouseHook from airflow.hooks.clickhouse_hook
from airflow.hooks.clickhouse_hook import ClickHouseHook
This is no problem. No import errors here.
But when I try:
import airflow.hooks.clickhouse_hook
I have an error:
ModuleNotFoundError: No module named 'airflow.hooks.clickhouse_hook'
And I can't understand how it works? I have no module named clickhouse_hook in directory airflow.hooks, but how can I import class ClickHouseHook without error in this way?
There is no ClickHouse provider in Airflow.
I assume you are using clickhouse plugin
thus the clickhouse_hook file is not in airflow/hooks folder because it is not part of Airflow.
I tried to import sqlalchemy to my pytest file but when I tried to run it shows this error, even though I have already installed sqlalchemy.
new.py:1: in <module>
import sqlalchemy
E ImportError: No module named sqlalchemy
my code :
import pytest
import sqlalchemy
the code was just when I was importing the sqlalchemy.
How do I fix it? Thanks in advance
I had the same, and fixed by running tests with:
python -m pytest .
Why is _mysql in the MySQLdb module a C file? When the module tries to import it, I get an import error. What should I do?
It's the adaptor that sits between the Python MySQLdb module and the C libmysqlclient library. One of the most common reasons for it not loading is that the appropriate libmysqlclient library is not in place.
Edit: This might be the answer to your question.
When I try to import _mysql, I get no error:
import _mysql
print(_mysql)
# <module '_mysql' from '/usr/lib/pymodules/python2.6/_mysql.so'>
It is importing the library /usr/lib/pymodules/python2.6/_mysql.so
If this is not what you are getting, it sounds like an installation error.
What OS are you using?
How did you install mysqldb?