0

My colleague is unable to debug in VS Code using a Python Azure Function our organization uses. When cloning the repository for the function, she is prompted to create a virtual environment, but no Python version is found under this prompt:
Select a Python interpreter to create a virtual environment

She has tried both manually entering her Python interpreter full path and creating a virtual environment manually in the integrated terminal, but the function will not start when debugging. However, the function does start using func start in the terminal. We have followed all the steps here and ensured all the required packages are installed: https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-python

When I try to reproduce the issue, I'm also prompted to create a virtual environment, but my interpreter shows up and the environment is successfully created. I am using Python 3.7.9 and my colleague is using 3.8.3. We're both using Anaconda versions of Python.

We have also attempted to manually run:

python -m venv .venv
.venv\Scripts\activate && pip install -r requirements.txt

in the terminal, but we are seeing this error when we attempt to debug:

> Executing task: .venv\Scripts\python -m pip install -r requirements.txt <

activate does not accept more than one argument:
['C:\\Users\\ddx\\anaconda3', '/d', '/c', '.venv\\Scripts\\python', '-m', 'pip', 'install', '-r', 'requirements.txt']
ddx
  • 469
  • 2
  • 9
  • 27
  • I met similar issue with this, please ask him to have a try with install python 3.7.9 which same with you. – Hury Shen Feb 12 '21 at 06:04
  • I had similar problem when I installed python 3.9 and can't solve it until I re-install another version python 3.8.6. I can't remeber if I also did some other configuration to solve it at that time. Please have a try with re-install another python version, if still can't solve the problem, I will do some more research and help you on it. – Hury Shen Feb 12 '21 at 06:10
  • @ddx -Is the python interpreter displayed in the lower left corner of her VS Code? And can it debug ordinary python scripts? Please check whether the path of "python3.8.3" used is in the python environment variable. – Jill Cheng Feb 12 '21 at 08:56
  • 1
    Thanks @HuryShen and @JillCheng. We have tried both reinstalling and adding Python to the system path environment variables and that did correct one of the errors we were seeing, but we are still seeing the `activate does not accept more than one argument:` which seems to be coming from the tasks.json file. – ddx Feb 12 '21 at 19:36

1 Answers1

1

We have found a workaround to get debugging work. The activate does not accept more than one argument error happens in tasks.json on the pipInstall requirement. After removing that requirement, we were able to get the function to debug. It doesn't look the function is actually running in the virtual environment, it is using the conda environment. But we are able to debug at least.

ddx
  • 469
  • 2
  • 9
  • 27