Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named '__main__' #1094

Closed
gavin-aguiar opened this issue Aug 23, 2022 · 5 comments
Closed

ModuleNotFoundError: No module named '__main__' #1094

gavin-aguiar opened this issue Aug 23, 2022 · 5 comments
Assignees

Comments

@gavin-aguiar
Copy link
Contributor

gavin-aguiar commented Aug 23, 2022

Announcement

We have identified an issue with a subset of python functions apps which have imported libraries like python-dotenv are seeing an error with functions runtime 4.9.1 and above.

The function apps are failing with the following error:

`Microsoft.Azure.WebJobs.Host.FunctionInvocationException : 
Exception while executing function: Functions.HttpTrigger ---> Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : 
Result: Failure Exception: ModuleNotFoundError: No module named '__main__' 
Stack: 
File '/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py', line 448, in _handle__invocation_request call_result = await self._loop.run_in_executor( 
File '/usr/local/lib/python3.9/concurrent/futures/thread.py', line 58, in run result = self.fn(*self.args, **self.kwargs) 
File '/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/dispatcher.py', line 691, in _run_sync_func return ExtensionManager.get_sync_invocation_wrapper(context, 
File '/azure-functions-host/workers/python/3.9/LINUX/X64/azure_functions_worker/extension.py', line 215, in _raw_invocation_wrapper result = function(**args) 
File '/home/site/wwwroot/HttpTrigger/__init__.py', line 8, in main return func.HttpResponse(f'Dotenv: {load_dotenv(find_dotenv())}') 
File '/home/site/wwwroot/.python_packages/lib/site-packages/dotenv/main.py', line 284, in find_dotenv if usecwd or _is_interactive() or getattr(sys, 'frozen', False): 
File '/home/site/wwwroot/.python_packages/lib/site-packages/dotenv/main.py', line 281, in _is_interactive main = __import__('__main__', None, None, fromlist=['__file__']) `

Mitigation

Add the app setting PYTHON_ISOLATE_WORKER_DEPENDENCIES to 0 as described in the documentation here

Fix

The fix is being rolled out and will be available in runtime versions 1.10.2 and higher.

@af-jka
Copy link

af-jka commented Sep 8, 2022

Same issue here since about 3 weeks.

@waltherg
Copy link

waltherg commented Dec 6, 2022

Still seeing this and really holding us back here on runtime version 4.14.0.0.

@vijaykumar911 vijaykumar911 unpinned this issue Apr 24, 2023
@drewsilcock
Copy link

I am still seeing this on uk-south premium plan. Combined with #1050 this issue blocks use of Tensorflow and Dill on Azure Functions.

@gavin-aguiar
Copy link
Contributor Author

I am still seeing this on uk-south premium plan. Combined with #1050 this issue blocks use of Tensorflow and Dill on Azure Functions.

@drewsilcock Have you enabled PYTHON_ISOLATE_WORKER_DEPENDENCIES in your app settings? Also, could you share your requirements.txt?

@drewsilcock
Copy link

I am still seeing this on uk-south premium plan. Combined with #1050 this issue blocks use of Tensorflow and Dill on Azure Functions.

@drewsilcock Have you enabled PYTHON_ISOLATE_WORKER_DEPENDENCIES in your app settings? Also, could you share your requirements.txt?

I have PYTHON_ISOLATE_WORKER_DEPENDENCIES set to 1 as a necessary step to fixing issues #1217 and #1050.

I can since figured out a hacky workaround for this issue that doesn't require setting PYTHON_ISOLATE_WORKER_DEPENDENCIES to 0, which is simply to create the file __main__.py in the folder of my function and then put

import os
import path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__))))

at the top of the __init__.py for the function - this unblocks me from being able to use these libraries, but obviously isn't an ideal solution.

For reference, requirements.txt:

absl-py==1.4.0 ; python_version >= "3.9" and python_version < "3.10"
aiohttp==3.8.4 ; python_version >= "3.9" and python_version < "3.10"
aiosignal==1.3.1 ; python_version >= "3.9" and python_version < "3.10"
alembic==1.10.4 ; python_version >= "3.9" and python_version < "3.10"
astunparse==1.6.3 ; python_version >= "3.9" and python_version < "3.10"
async-cache==1.1.1 ; python_version >= "3.9" and python_version < "3.10"
async-timeout==4.0.2 ; python_version >= "3.9" and python_version < "3.10"
attrs==23.1.0 ; python_version >= "3.9" and python_version < "3.10"
azure-core==1.26.4 ; python_version >= "3.9" and python_version < "3.10"
azure-cosmos==4.3.1 ; python_version >= "3.9" and python_version < "3.10"
azure-eventhub==5.11.2 ; python_version >= "3.9" and python_version < "3.10"
azure-functions==1.13.3 ; python_version >= "3.9" and python_version < "3.10"
azure-storage-blob==12.16.0 ; python_version >= "3.9" and python_version < "3.10"
binaryornot==0.4.4 ; python_version >= "3.9" and python_version < "3.10"
cachetools==5.3.0 ; python_version >= "3.9" and python_version < "3.10"
certifi==2022.12.7 ; python_version >= "3.9" and python_version < "3.10"
cffi==1.15.1 ; python_version >= "3.9" and python_version < "3.10"
chardet==5.1.0 ; python_version >= "3.9" and python_version < "3.10"
charset-normalizer==3.1.0 ; python_version >= "3.9" and python_version < "3.10"
click==8.1.3 ; python_version >= "3.9" and python_version < "3.10"
cloudpickle==2.2.1 ; python_version >= "3.9" and python_version < "3.10"
colorama==0.4.6 ; python_version >= "3.9" and python_version < "3.10" and platform_system == "Windows"
comtrade==0.0.10 ; python_version >= "3.9" and python_version < "3.10"
contourpy==1.0.7 ; python_version >= "3.9" and python_version < "3.10"
cryptography==40.0.2 ; python_version >= "3.9" and python_version < "3.10"
cycler==0.11.0 ; python_version >= "3.9" and python_version < "3.10"
databricks-cli==0.17.6 ; python_version >= "3.9" and python_version < "3.10"
decorator==5.1.1 ; python_version >= "3.9" and python_version < "3.10"
dill==0.3.4 ; python_version >= "3.9" and python_version < "3.10"
dm-tree==0.1.8 ; python_version >= "3.9" and python_version < "3.10"
docker==6.0.1 ; python_version >= "3.9" and python_version < "3.10"
entrypoints==0.4 ; python_version >= "3.9" and python_version < "3.10"
flask==2.2.3 ; python_version >= "3.9" and python_version < "3.10"
flatbuffers==23.3.3 ; python_version >= "3.9" and python_version < "3.10"
fonttools==4.39.3 ; python_version >= "3.9" and python_version < "3.10"
frozenlist==1.3.3 ; python_version >= "3.9" and python_version < "3.10"
gast==0.4.0 ; python_version >= "3.9" and python_version < "3.10"
gitdb==4.0.10 ; python_version >= "3.9" and python_version < "3.10"
gitpython==3.1.31 ; python_version >= "3.9" and python_version < "3.10"
google-auth-oauthlib==1.0.0 ; python_version >= "3.9" and python_version < "3.10"
google-auth==2.17.3 ; python_version >= "3.9" and python_version < "3.10"
google-pasta==0.2.0 ; python_version >= "3.9" and python_version < "3.10"
greenlet==2.0.2 ; python_version >= "3.9" and platform_machine == "aarch64" and python_version < "3.10" or python_version >= "3.9" and platform_machine == "ppc64le" and python_version < "3.10" or python_version >= "3.9" and platform_machine == "x86_64" and python_version < "3.10" or python_version >= "3.9" and platform_machine == "amd64" and python_version < "3.10" or python_version >= "3.9" and platform_machine == "AMD64" and python_version < "3.10" or python_version >= "3.9" and platform_machine == "win32" and python_version < "3.10" or python_version >= "3.9" and platform_machine == "WIN32" and python_version < "3.10"
grpcio==1.54.0 ; python_version >= "3.9" and python_version < "3.10"
gunicorn==20.1.0 ; python_version >= "3.9" and python_version < "3.10" and platform_system != "Windows"
h5py==3.8.0 ; python_version >= "3.9" and python_version < "3.10"
idna==3.4 ; python_version >= "3.9" and python_version < "3.10"
importlib-metadata==5.2.0 ; python_version >= "3.9" and python_version < "3.10"
importlib-resources==5.12.0 ; python_version >= "3.9" and python_version < "3.10"
isodate==0.6.1 ; python_version >= "3.9" and python_version < "3.10"
itsdangerous==2.1.2 ; python_version >= "3.9" and python_version < "3.10"
jax==0.4.8 ; python_version >= "3.9" and python_version < "3.10"
jinja2==3.1.2 ; python_version >= "3.9" and python_version < "3.10"
joblib==1.2.0 ; python_version >= "3.9" and python_version < "3.10"
keras==2.12.0 ; python_version >= "3.9" and python_version < "3.10"
kiwisolver==1.4.4 ; python_version >= "3.9" and python_version < "3.10"
libclang==16.0.0 ; python_version >= "3.9" and python_version < "3.10"
mako==1.2.4 ; python_version >= "3.9" and python_version < "3.10"
markdown==3.4.3 ; python_version >= "3.9" and python_version < "3.10"
markupsafe==2.1.2 ; python_version >= "3.9" and python_version < "3.10"
matplotlib==3.7.1 ; python_version >= "3.9" and python_version < "3.10"
ml-dtypes==0.1.0 ; python_version >= "3.9" and python_version < "3.10"
mlflow==1.30.1 ; python_version >= "3.9" and python_version < "3.10"
multidict==6.0.4 ; python_version >= "3.9" and python_version < "3.10"
numpy==1.23.5 ; python_version >= "3.9" and python_version < "3.10"
oauthlib==3.2.2 ; python_version >= "3.9" and python_version < "3.10"
opt-einsum==3.3.0 ; python_version >= "3.9" and python_version < "3.10"
packaging==21.3 ; python_version >= "3.9" and python_version < "3.10"
pandas==1.5.3 ; python_version >= "3.9" and python_version < "3.10"
pillow==9.5.0 ; python_version >= "3.9" and python_version < "3.10"
plotly==5.14.1 ; python_version >= "3.9" and python_version < "3.10"
prometheus-client==0.16.0 ; python_version >= "3.9" and python_version < "3.10"
prometheus-flask-exporter==0.22.3 ; python_version >= "3.9" and python_version < "3.10"
protobuf==4.22.3 ; python_version >= "3.9" and python_version < "3.10"
psycopg-binary==3.1.8 ; python_version >= "3.9" and python_version < "3.10"
psycopg-c==3.1.8 ; python_version >= "3.9" and python_version < "3.10"
psycopg-pool==3.1.7 ; python_version >= "3.9" and python_version < "3.10"
psycopg[c,pool]==3.1.8 ; python_version >= "3.9" and python_version < "3.10"
pyasn1-modules==0.3.0 ; python_version >= "3.9" and python_version < "3.10"
pyasn1==0.5.0 ; python_version >= "3.9" and python_version < "3.10"
pycparser==2.21 ; python_version >= "3.9" and python_version < "3.10"
pydantic==1.10.7 ; python_version >= "3.9" and python_version < "3.10"
pydantic[dotenv]==1.10.7 ; python_version >= "3.9" and python_version < "3.10"
pyjwt==2.6.0 ; python_version >= "3.9" and python_version < "3.10"
pyparsing==3.0.9 ; python_version >= "3.9" and python_version < "3.10"
python-dateutil==2.8.2 ; python_version >= "3.9" and python_version < "3.10"
python-dotenv==1.0.0 ; python_version >= "3.9" and python_version < "3.10"
pytz==2022.7.1 ; python_version >= "3.9" and python_version < "3.10"
pywin32==306 ; python_version >= "3.9" and python_version < "3.10" and sys_platform == "win32"
pyyaml==6.0 ; python_version >= "3.9" and python_version < "3.10"
querystring-parser==1.2.4 ; python_version >= "3.9" and python_version < "3.10"
redis==4.5.4 ; python_version >= "3.9" and python_version < "3.10"
requests-oauthlib==1.3.1 ; python_version >= "3.9" and python_version < "3.10"
requests==2.28.2 ; python_version >= "3.9" and python_version < "3.10"
rsa==4.9 ; python_version >= "3.9" and python_version < "3.10"
scikit-learn==1.0.2 ; python_version >= "3.9" and python_version < "3.10"
scipy==1.10.1 ; python_version >= "3.9" and python_version < "3.10"
setuptools==67.7.2 ; python_version >= "3.9" and python_version < "3.10"
six==1.16.0 ; python_version >= "3.9" and python_version < "3.10"
smmap==5.0.0 ; python_version >= "3.9" and python_version < "3.10"
sqlalchemy==1.4.47 ; python_version >= "3.9" and python_version < "3.10"
sqlparse==0.4.4 ; python_version >= "3.9" and python_version < "3.10"
tabulate==0.9.0 ; python_version >= "3.9" and python_version < "3.10"
tenacity==8.2.2 ; python_version >= "3.9" and python_version < "3.10"
tensorboard-data-server==0.7.0 ; python_version >= "3.9" and python_version < "3.10"
tensorboard-plugin-wit==1.8.1 ; python_version >= "3.9" and python_version < "3.10"
tensorboard==2.12.2 ; python_version >= "3.9" and python_version < "3.10"
tensorflow-estimator==2.12.0 ; python_version >= "3.9" and python_version < "3.10"
tensorflow-io-gcs-filesystem==0.32.0 ; python_version >= "3.9" and python_version < "3.10" and platform_machine != "arm64" or python_version >= "3.9" and python_version < "3.10" and platform_system != "Darwin"
tensorflow-probability==0.18.0 ; python_version >= "3.9" and python_version < "3.10"
tensorflow==2.12.0 ; python_version >= "3.9" and python_version < "3.10"
termcolor==2.3.0 ; python_version >= "3.9" and python_version < "3.10"
threadpoolctl==3.1.0 ; python_version >= "3.9" and python_version < "3.10"
tqdm==4.65.0 ; python_version >= "3.9" and python_version < "3.10"
typing-extensions==4.5.0 ; python_version >= "3.9" and python_version < "3.10"
tzdata==2023.3 ; python_version >= "3.9" and python_version < "3.10" and sys_platform == "win32"
urllib3==1.26.15 ; python_version >= "3.9" and python_version < "3.10"
waitress==2.1.2 ; python_version >= "3.9" and python_version < "3.10" and platform_system == "Windows"
websocket-client==1.5.1 ; python_version >= "3.9" and python_version < "3.10"
werkzeug==2.2.3 ; python_version >= "3.9" and python_version < "3.10"
wheel==0.40.0 ; python_version >= "3.9" and python_version < "3.10"
wrapt==1.14.1 ; python_version >= "3.9" and python_version < "3.10"
xarray==0.21.1 ; python_version >= "3.9" and python_version < "3.10"
yarl==1.9.1 ; python_version >= "3.9" and python_version < "3.10"
zipp==3.15.0 ; python_version >= "3.9" and python_version < "3.10"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants