Skip to content

[BUG] .venv not in sys.path (?) #1159

@Clam-

Description

@Clam-

Investigative information

Please provide the following:
  • Timestamp: 2022-12-31T04:56:29.748Z
  • Function App name: newazurefunc
  • Function name(s) (as appropriate): mytimer
  • Core Tools Version: 4.0.4915 Commit hash: N/A (64-bit)
  • Function Runtime Version: 4.14.0.19631
  • Python 3.9.13

Repro steps

Provide the steps required to reproduce the problem:
  1. Open VSCode
  2. Click Azure button
  3. Click Create Function button
  4. Create new folder C:\test\NewFunc2
  5. Select folder created above
  6. at "Select a language" prompt select: "python (Programming Model V2)"
  7. Select a Python interpreter to create a virtual environment: "python3 3.9.13"
    (also tried "python 3.9.4")
  8. Select "Open in current window"
  9. Edit "requirements.txt" add new line "requests"
  10. Change body of "function_app.py" to be:
import azure.functions as func
import logging
import datetime
import requests 
app = func.FunctionApp()
@app.function_name(name="mytimer")
@app.schedule(schedule="0 */5 * * * *", arg_name="mytimer", run_on_startup=True,
              use_monitor=False) 
def test_function(mytimer: func.TimerRequest) -> None:
    utc_timestamp = datetime.datetime.utcnow().replace(
        tzinfo=datetime.timezone.utc).isoformat()
    if mytimer.past_due:
        logging.info('The timer is past due!')
    logging.info('Python timer trigger function ran at %s', utc_timestamp)
  1. press F5
  2. "Exception: ModuleNotFoundError: No module named 'requests'."

Expected behavior

Provide a description of the expected behavior.

Expected the function to run without import error

Actual behavior

Provide a description of the actual behavior observed.
Error in index_function_app. Sys Path: ['C:\\Users\\<>\\AppData\\Roaming\\npm\\node_modules\\azure-functions-core-tools\\bin\\workers\\python\\3.9\\WINDOWS\\X64', 
'C:\\Users\\<>\\AppData\\Roaming\\npm\\node_modules\\azure-functions-core-tools\\bin\\workers\\python\\3.9\\WINDOWS\\X64', 
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\\python39.zip', 
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\\DLLs', 
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\\lib', 
'C:\\Users\\<>\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0', 
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0', 
'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\\lib\\site-packages', 
'C:\\test\\NewAzureFunc'],

Known workarounds

Provide a description of any known workarounds.

I've tried a lot of things short of manually injecting into sys.path to no avail.

Contents of the requirements.txt file:

Provide the requirements.txt file to help us find out module related issues.
azure-functions
requests

Related information

Provide any related information

n/a

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions