0

I am using this command:

python -m virtualenv venv

and this is what comes out:

C:\Users\dell\AppData\Local\Programs\Python\Python310\python.exe: No module named virtualenv`

Freddy Mcloughlan
  • 4,129
  • 1
  • 13
  • 29
NESKI
  • 1
  • 2
  • 1
    The name of the module is `venv`, not `virtualenv`. So the command should be `python -m venv venv` – Serge Ballesta Jun 21 '22 at 12:18
  • I think this answer provides a detailed explanation of virtual environments in python. You will understand virtualenv and venv: https://stackoverflow.com/a/41573588/1836069 – Olasimbo Jun 21 '22 at 12:30

2 Answers2

1

as Serge mentioned in the comments, your command is incorrect. Instead it should be: python3 -m venv /path/to/new/virtual/environment

see this for more info https://docs.python.org/3/library/venv.html

0

Are you using Python3 or Python2?

If Python2, use the virtualenv command. You'll first need to install e.g. py -m pip install --user virtualenv. Then you can create the environment: py -m virtualenv myenv (where 'myenv' can be any name you want to call the environment). Then you can activate it using: source myenv/bin/activate.

If you are using Python3, use the venv command instead. I'm not a Windows user, but I don't think you have to install if using Python3, so you can go straight to creating the environment). Create the environment using: py -m venv myenv (again, 'myenv' can be renamed). Then you activate the environment in the same way as above (source myenv/bin/activate).

This Python documentation (https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/) explains in detail.

graceface
  • 111
  • 5