42
I have been facing the exact same problem. Finally found a workaround from a forum (https://github.com/Microsoft/vscode-python/issues/4434#issuecomment-466600591)
As long as you ADD some stuff to configuration, terminal.integrated.env.osx
, the content will be appended to PATH
after shell initialization(source bash_profile or zshrc). In my Mojave, I simply add following empty entry to my user configuration:
"terminal.integrated.env.osx": {
"PATH": ""
}
Then the $PATH
will be the same as the external terminal.
35
The officially accepted answer by @Samuel was the correct answer at the time.
But VS Code has now provided a better way to handle it.
In short, open up your user settings and add this line of code:
"terminal.integrated.inheritEnv": false,
This prevents stomping over whatever Python environment manager you are using (eg, venv, conda, etc).
- [Django]-Why second user login redirects me to /accounts/profile/ url in Django?
- [Django]-Prefetch_related for multiple Levels
- [Django]-Celery: When should you choose Redis as a message broker over RabbitMQ?
3
For Windows users:
First if you havenβt done already, set VS code (the editor, not its terminal) to the desired Python environment, using Ctrl+Shift+P --> Python: Select interpreter
.
Then, Change VS codeβs default terminal from Powershell to CMD. This is what worked for me at least.
- [Django]-Why is factory_boy superior to using the ORM directly in tests?
- [Django]-How do I use django rest framework to send a file in response?
- [Django]-How can I test binary file uploading with django-rest-framework's test client?
2
Windows Solution:
If anyone in the future ends up scratching their heads over this particular problem, Iβve found another culprit, which blocked me for this problem on Windows:
Terminal>Integrated>Env: Enable Persistent Sessions
I suspect what happens is that after you update system paths, VScode caches the old path in the terminal and persists it. In this case it persists the old python path rather than the new conda one.
Toggling this option off and restarting VSCode clears that cache, and the new path is loaded in. You can also toggle the option back on after youβre done.
- [Django]-CSS styling in Django forms
- [Django]-AttributeError: 'ManyRelatedManager' object has no attribute 'add'? I do like in django website but got this error
- [Django]-Django auto_now and auto_now_add
1
I just ran into the same problem. Try switching out of the powershell terminal to the windows terminal. Then restart. It should restart with the anaconda terminal. If that does not work you could:
First change the default terminal from within Visual Code to the CMD terminal instead of Powershell. Add the following code to a batch file.
call "c:\path\to\anaconda3\Scripts\activate"
Then I named the batch file and saved it to my root directory. In my case snake.bat
. Now when I launch my CMD terminal I just type c:\snake.bat
and the CMD prompt changes into an Anaconda prompt.
- [Django]-Could not find a version that satisfies the requirement pkg-resources==0.0.0
- [Django]-How do I force Django to ignore any caches and reload data?
- [Django]-How to store a dictionary on a Django Model?
-1
I ran this script. Now python3 is running from virtual env. [Windows 10]
pip3 install virtualenv
virtualenv env
call ".\env\Scripts\activate.bat"
set requirements="./Requirements.txt"
pip3 install -r %requirements%
python
- [Django]-Django models.py Circular Foreign Key
- [Django]-Django self-referential foreign key
- [Django]-What is a Django "app" supposed to mean?