2

I've been told that to activate a Virtual Environment in Django for Windows I should try:

environment_path\Scripts\activate

But when I enter that, cmd returns this error:

The system cannot find the path specified.

I created the virtual environment by entering:

python3 -m venv env

However when I try env\Scripts\activate I get the error described.

Can anyone help? Thanks.

3 Answers 3

2

Activating a virtual environment on Windows depends on where you are running it from. From the Windows Command Prompt, the command is:

  • environment_path\Scripts\activate.bat

If the Git-Bash shell is being used, which adds several useful tools and a more Unix/Linux-like environment, then the command is:

  • source environment_path\Scripts\activate

I have found the prerequisites section of Test-Driven Development with Python aka "the Testing Goat book" to be handy in getting Django, Python and related things setup on Windows.

Sign up to request clarification or add additional context in comments.

6 Comments

when I try "source environment_path\Scripts\activate" I get the following error: "'source' is not recognized as an internal or external command". From what I've read, "source" does not work with Windows.
If you are using 'Command Prompt' then you want environment_path\Scripts\activate.bat instead.I would recommend getting the Git for Windows binary and following the instructions under the 'Windows Notes' in the Prerequisites section in the TDD book to install the Git-Bash shell which is much nicer than the standard Windows command prompt
I am using command prompt. environment_path\Scripts\activate.bat does not work either.
How does the .bat not work ? I have both Python3.6 and Python3.7 installed and neither provide a python3 executable. If I run C:\Python37\python.exe -m venv test_venv, then test_venv\Scripts\activate.bat works fine. Maybe you have an odd version of python and can try reinstalling from www.python.org/downloads ? Or try creating a fresh venv ?
Well I ran env\Scripts\activate.bat and I get the same error, "The system cannot find the path specified." I ran python3 -m venv env to create the virtual environment in the first place... am I perhaps entering something wrong there which means it's not creating the virtual environment? Thanks for your patience.
|
2

You can create virtual environment in windows as: py -m venv myenv (Here myenv is the name that users give. It can be anything you want)

Now to activate your myenv virtual environment type:myenv\scripts\activate

To deactivate virtual environment simply type: deactivate

Comments

0

If you are using windows 7, then try environment_path\Scripts\activate.ps1

Also, error is saying, The system cannot find the path specified., make sure your path is correct.

Remember scripts folder is in your virtualenv folder.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.