Skip to content
Advertisement

pip command not found in virtual env even if file is there

These are the steps I did:

  1. Created a virtual env using python3 -m venv myvenv
  2. Activate the virtual env using myvenv/bin/activate
  3. Run python -m pip install --upgrade pip, to upgrade pip.
  4. run pip install -r requirements.txt
  5. It throws an error: bash: /Users/vince/Django Projects/test/myvenv/bin/pip: "/Users/vince/Django: bad interpreter: No such file or directory

When I tried using pip2 install, it works, why is that so?

Is there something I missed?

Advertisement

Answer

The file /Users/vince/Django Projects/test/myvenv/bin/pip starts with shebang /Users/vince/Django Projects/test/myvenv/bin/python (look it up). The problem is the path contains a space in its name and shebangs are not allowed to have spaces.

Remove the virtualenv, it’s unusable. Recreate it under a path that doesn’t have spaces and other fancy characters.

Upd. You can run scripts manually:

"/Users/vince/Django Projects/test/myvenv/bin/python" "/Users/vince/Django Projects/test/myvenv/bin/pip"

But that’s painful.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement