0

My code runner in VS Code is not executing code in virtual environment. I have looked for multiple solutions in existing threads here and outside. Even after multiple attempts it does not work. I have attached reference of each attempts.

Attempt 1:

"python": "C:\\Users\\Farhan Hasant\\.virtualenvs\\HelloWorld--L5nr0Hr\bin\\python -u",

Result

Attempt 2:

"python": "$pythonPath -u $fullFileName",

Result

Virtual Environment Path: Virtual Env path

I have created the virtual environment using pip install pipenv and installed requests package using pip env install requests.

Farhanhasnat
  • 89
  • 14
  • Seems that the issue is that the space in the path of the wrapper – cgcgbcbc Feb 24 '19 at 07:16
  • I tried removing the space too but it does not seem to work, – Farhanhasnat Feb 24 '19 at 08:36
  • You can't remove it if it's there in the path, but you can probably escape it with a backslash, e.g. `Farhan\ Hasant`. – Brett Cannon Feb 26 '19 at 00:27
  • @BrettCannon I tried using the escape character but does not seem to work either. Prompts me with the same error. Thank you for you support though ! – Farhanhasnat Feb 26 '19 at 09:06
  • Here you may look some useful advice. It helped me https://stackoverflow.com/questions/29987840/how-to-execute-python-code-from-within-visual-studio-code – rastok Mar 23 '20 at 05:01

1 Answers1

0

From the documentation, it states that if there is a space within your file path, you should add \" to open and close the said file path with blanks.

"python": "\"C:\\Users\\Farhan Hasant\\.virtualenvs\\HelloWorld--L5nr0Hr\bin\\python\" 
&& python -u" 

This should work!

Bueeny
  • 1