Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
44 views
in Technique[技术] by (71.8m points)

python - Azure app service cannot find installed modules

I am attempting to deploy a Django app to a Linux server via an Azure App Service. During the deployment via Azure Devops Pipelines, all requirements are installed from my requirements.txt file in the root directory of my project.

I have used the Kudu console to confirm the dependencies are installed to /antenv/lib/python3.7/site-packages on the server, however, the app crashes due to an error:

ModuleNotFoundError: No module named 'django'

I am beginning to think the virtual environment may be failing to actually start but do not know how to check or how to start it if this is the case.

Has anyone had a similar issue to this during their deployment? If so how did you resolve it? Any advise is much appreciated. Thank you!

question from:https://stackoverflow.com/questions/65911260/azure-app-service-cannot-find-installed-modules

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Newest

Change target path ,--target="./.python_packages/lib/site-packages" .

- bash: |
   python3.8 -m venv worker_venv
   source worker_venv/bin/activate
   pip3.8 install setuptools
   pip3.8 install --target="./.python_packages/lib/site-packages" -r requirements.txt
   displayName: 'Install Application Dependencies'

You need to install a new Python runtime at the path D:home via Kudu site extensions.(Windows)

The problems is, azure app service use virtualenv by default, so the requirements.txt package is automaticly installed to python in the virtualenv... so I just edit the deploy.cmd to install requirements to python (extension)

For more details, you can refer Peter Pan's answer in below post.

Why is the azure app service django deploy keep failing?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...