4

There is a similar question but it does not deal with my error:

On trying to install a virtual environment using CMD in the E drive, I used this command:

E:\myproject>venv\Scripts\activate

The error that occurred was:

'venv\Scripts\activate' is not recognized as an internal or external command,
operable program or batch file.

What exactly are the steps required to install flask - the documentation was followed step by step and did not work.

You can trace my steps, and I keep getting stuck here. What am I doing wrong?

E:\>mkdir myproject

E:\>cd myproject

E:\myproject>python3 -m venv venv

E:\myproject>py -3 -m venv venv
Error: Command '['E:\\myproject\\venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3221226505.

E:\myproject>venv\Scripts\activate
'venv\Scripts\activate' is not recognized as an internal or external command,
operable program or batch file.

E:\myproject>

Note: You'll see that I've followed the steps for creating a virtual environment from here: https://flask.palletsprojects.com/en/1.1.x/installation/#virtual-environments

I also tried the following, but also resulting in an error:

E:\myproject>py -3 -m venv venv
Error: Command '['E:\\myproject\\venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 3221226505.

E:\myproject>

I tried to enter the venv itself and tried this - again a different error. I think I am missing something very basic.

E:\myproject>cd venv

E:\myproject\venv>venv\Scripts\activate
The system cannot find the path specified.

I also tried: (based on a stackoverflow answer)

E:\myproject\venv>pip install virtualenv

Again, an error.

and

E:\myproject\venv>py -3.8 -m venv venv

still, nothing.

Another point that may be of interest/relevance:

In the E drive ,I installed PYTHON 3.8.3 in the root directory. I am obviously creating the various folders e.g. myproject also in the root directory. E: mkdir myproject

Does the path affect anything? I am now deinstalling and re-installing python.

I am ensuring that I am checking the little tick that says "add python to environment path" (which I hadn't earlier).

On reinstalling: this occured:

E:\>mkdir myproject

E:\>cd myproject

E:\myproject>python --version
Python 3.8.3

E:\myproject>python3 -m venv venv

E:\myproject>venv\Scripts\activate
The system cannot find the path specified.

E:\myproject>

A slightly different error, I note, but still CANNOT FIND THE PATH related.

Finally, I tried creating the dir and venv in the actual folder where python was is installed: Still, an error

E:\>cd Python installation
E:\Python installation>mkdir myproject
E:\Python installation>cd myproject
E:\Python installation\myproject>python3 -m venv venv
E:\Python installation\myproject>venv\Scripts\activate
The system cannot find the path specified.
E:\Python installation\myproject>
Compoot
  • 2,227
  • 6
  • 31
  • 63
  • So `python3 -m venv venv` worked? – ForceBru Jun 23 '20 at 20:32
  • No, it did not. – Compoot Jun 23 '20 at 20:36
  • I'd say it did because 1) it didn't raise any errors and 2) you were able to `cd` into `venv`, which presumably wasn't there before you ran the command. – ForceBru Jun 23 '20 at 20:41
  • ForceBru -I'm not talking about the venv part - but the activate. That's the part that is not working – Compoot Jun 23 '20 at 20:43
  • Does the `venv` directory exist? Does `venv\Scripts` exist? Does `venv\Scripts\activate` exist? – ForceBru Jun 23 '20 at 20:44
  • It did...but now even that is not appearing in 'myproject', So now - no – Compoot Jun 23 '20 at 20:47
  • The following, doesn't come up with an error. It just does nothing: E:\Python installation\myproject>python3 -m venv venv E:\Python installation\myproject> – Compoot Jun 23 '20 at 20:47
  • --------------------------- Serenity's Unicode Text Editor --------------------------- NT Status 0xC0000409 (-1073740791 32 bit and 3221226505 64 bit) Windows Error 0x502 (1282) **NT Status Message:** The system detected an overrun of a stack-based buffer in this application. This overrun could potentially allow a malicious user to gain control of this application. **Windows Error Message** The system detected an overrun of a stack-based buffer in this application. This overrun could potentially allow a malicious user to gain control of this application. –  Jun 23 '20 at 21:00
  • Does this answer your question? [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/questions/41454769/what-is-the-reason-for-x-is-not-recognized-as-an-internal-or-external-command) – aschipfl Jun 24 '20 at 07:14

2 Answers2

5

Frustrating, as I followed the official flask tutorial and it didn't work. This, however, did:

I hope someone finds this useful.

E:\Python installation\myproject>py -m venv env
E:\Python installation\myproject>env\Scripts\activate
(env) E:\Python installation\myproject>

Note that in the first step i typed in py -m venv env instead of py -m venv venv (as suggested on the official docs)

Compoot
  • 2,227
  • 6
  • 31
  • 63
  • py -m venv env is the official documented command. Good to know you succeeded! – Teja Jun 23 '20 at 20:54
  • I use PyCharm as a visual management tool for venv. It removes the hassle. After creating the venv folder, if you prefer coding in VSCode, simply open the project folder and it will automatically activate the environment for you. If you want easily maintainable envs, it could be a thing to try. – Huy Apr 06 '21 at 10:26
3

Please try this:

Go to your project directory (myproject) and then:

.\venv\Scripts\activate
Teja
  • 305
  • 1
  • 6
  • E:\myproject>.\venv\Scripts\activate '.\venv\Scripts\activate' is not recognized as an internal or external command, operable program or batch file. E:\myproject> – Compoot Jun 23 '20 at 20:36
  • Thanks for your try - I didn't downvote you. But no, it didn't work. – Compoot Jun 23 '20 at 20:40
  • So, guess the question is not clear for me. I thought you were trying to activate an existing virtual environment. You were not able to create one? – Teja Jun 23 '20 at 20:52