3

I installed 'virtualenv' with

pip install virtualenv

Installing collected packages: virtualenv

Successfully installed virtualenv-16.0.0

However, when I run 'virtualenv project1' it gives me this error:

**ModuleNotFoundError: No module named 'virtualenv'**

It happens with every package I tried to install. I have python2 and python3 at the same time. I suspect that is messing up everything. Does anyone know how to fix this?

Jenn
  • 31
  • 1
  • 2
  • 4
  • when you pip freeze, do you see it installed? Also, don't run it from the python IDLE or shell. – dfundako Jun 14 '18 at 17:13
  • 3
    Possible duplicate of [ImportError: No module named virtualenv](https://stackoverflow.com/questions/21070369/importerror-no-module-named-virtualenv) – tripleee Jun 14 '18 at 17:14

1 Answers1

7

I have python2 and python3 at the same time.

you are likely installing for Python3 but trying to run with Python2 (or vice versa)

for installing into Python2, use:

python -m pip install <package>

for installing into Python3, use:

python3 -m pip install <package>
Corey Goldberg
  • 59,062
  • 28
  • 129
  • 143
  • Concur. With multiple installs, I always use the `-m` flag and point directly to the interpreter I want. – pstatix Jun 14 '18 at 17:30
  • 1
    @pstatix Yeah, and the PyPA have even changed the docs a while back to make this the officially-recommended way to do it. That way you only need to know how to find one executable, and you know you’re using it consistently no matter what else is on your PATH, which isn’t true when you run a bunch of related separate ones. – abarnert Jun 14 '18 at 17:38