Reputation: 477
I'm trying to schedule a python script that uses an extension module in an Azure web job:
import sys
sitepackage = "D:\home\site\wwwroot\env\Lib\site-packages"
sys.path.append(sitepackage)
try:
from bs4 import BeautifulSoup
print("!!! BEAUTIFUL SOUP !!!")
except ImportError as e:
print(e)
I have all the appropriate extension modules pip installed in my (venv) inside of my 'site-packages' folder:
But it fails to run because it cannot import beautifulsoup4 from bs4:
error: "No module named bs4"
Upvotes: 2
Views: 1187
Reputation: 21
Just adding some additional information. Also, make sure you follow the above instructions with installing python with the extensions. If you are running in Windows Environment. What worked for me is to have a folder with:
Example of run.cmd below:
set PYTHON_PATH=D:\home\python3111x64\python.exe
%PYTHON_PATH% -m pip install --upgrade -r requirements.txt
%PYTHON_PATH% run.py
Upvotes: 0
Reputation: 477
Okay, so I figured it out here's my solution and I'll explain each step in detail down below.
STEP 1 - Make sure you have python site extension in your App Service:
STEP 2 - Create and zip a folder for 3 items: your_file_name.py, run.bat, and requirements.txt
D:\home\python364x86\python.exe -m pip install --upgrade -r D:\home\site\wwwroot\App_Data\jobs\triggered\webjobname\zippedfoldername\requirements.txt
D:\home\python364x86\python.exe your_file_name.py
beautifulsoup4==4.9.3
bs4==0.0.1
soupsieve==2.2
urlopen==1.0.0
STEP 3 - Create a new Web Job with the new zipped folder
Upvotes: 2