The only solution I found was to delete the
venv and recreate it. I followed these steps but I’ll provide a brief summary for Windows:
- Activate your virtualenv. Go to the parent folder where your Virtual Environment is located and run
venv\scripts\activate. Keep in mind that the first name "venv" can vary.
- Create a requirements.txt file.
pip freeze > requirements.txt
deactivateto exit the venv
rm venvto delete the venv
py -m venv venvto create a new one
pip install -r requirements.txtto install the requirements.
"python.venvPath" setting (it doesn’t do what you seem to think it does), don’t specify these settings in your user settings, and change your
"python.pythonPath" to be relative to your project, e.g.:
In my case, it wasn’t sufficient to delete and recreate the venv, to select the venv from within VS Code, or to update the pythonPath to point to the venv. VS Code was still unable to find the venv or discover the unit tests. The issue turned out to be that I had reorganized my project folders so my project was no longer in the same location where I originally created its previous virtual environment. The only solution that worked was to delete the venv, move the project back to the same parent folder it was in before, then create a new venv.
- Can not use celery delay for saved form: object is not JSON serializable
- Django Testing – Hard code URLs or Not
- Django – Override admin site's login form
- How to render a Django form with RadioSelect without getting a checked radiobutton by default?
- PUT request for image upload not working in django rest
I found a solution for wsl users and maybe it’s happening to some of you.
If you did create the virtual enviroment in wsl mode Windows will never find the python file because there is not .exe in Linux systems, so the way to activate is
cd [folder where you have your venv]
activate folder -> source venv/bin/activate
Once you have your venv activated then open vs code
And you will have the enviroment activated.
- Django cms – invalid block tag endblock
- How do you update a Django Form Meta class fields dynamically from the form constructor?
- Use of python super function in django model
- Django 1.9 JSONField order_by
- Error: command 'x86_64-linux-gnu-gcc' when installing mysqlclient
The simple solution which worked for me is as follow:
- Open the VS Code Terminal
- Navigate (from your project folder) to folder containing the environment and activate as follow:
3.Navigate back to your project folder
- Django aggregation: sum then average
- Using django models across apps?
- Django template rows of multiple items
In my case, I had not yet installed
virtualenv. You can install it using:
pip install virtualenv
- Django Test Client post() returns 302 despite error on view's post()
- UnicodeEncodeError：'latin-1' codec can't encode characters in position 0-1: ordinal not in range(256)
- Overriding Size of Django Admin Multi-select Widget
- Django admin dropdown of 1000s of users
- Get the version of Django for application