0

enter image description here

I've just created a new user account called deployer in my 16.04 VPS and I'd like to create a virtualenv inside directory Env. However:

deployer@server:~$ cd Env/
deployer@server:~/Env$ virtualenv sample
-bash: virtualenv: command not found
deployer@server:~/Env$ which virtualenv
deployer@server:~/Env$

But when I run pip list I see:

deployer@server:~$ pip list
click (6.7)
....
uWSGI (2.0.14)
virtualenv (15.1.0)
virtualenv-clone (0.2.6)
virtualenvwrapper (4.7.2)

Why can't I access 'virtualenv' ?

Edit:

deployer@server:~$ find . -iname "virtualenv"
./.local/bin/virtualenv
deployer@server:~$ find /usr/ -iname "virtualenv" | grep bin
/usr/local/bin/virtualenv

edit2:

deployer@server:~$ find . -iname "virtualenv"
./.local/bin/virtualenv
deployer@server:~$ find /usr/ -iname "virtualenv" | grep bin
/usr/local/bin/virtualenv
/usr/bin/virtualenv
deployer@server:~$
4
  • 1
    This implies that virtualenv isn't installed. Have you installed it?
    – Josh
    Feb 4, 2017 at 1:54
  • No, but isn't it already installed? (given the pip list output?) Feb 4, 2017 at 3:27
  • Can you report the output of : find . -iname "virtualenv" and find /usr/ -iname "virtualenv" | grep bin
    – albert j
    Feb 4, 2017 at 4:53
  • Please see edit.. Feb 4, 2017 at 15:24

2 Answers 2

2

Both which virtualenv and find /usr/ -iname "virtualenv" | grep bin should return/usr/bin/virtualenv. virtualenv is not installed in the right directory. It should be installed in /usr/bin/virtualenv instead of /usr/local/bin/virtualenv so reinstall it.

sudo apt install --reinstall python-virtualenv  

For concise information about virtualenv basic usage visit Virtual Environments — The Hitchhiker's Guide to Python.

4
  • please see edit 2: Feb 4, 2017 at 16:42
  • I'm confused about this .local directory. Why is this being used? Feb 4, 2017 at 16:48
  • Also how does "sudo apt install --reinstall python-virtualenv " differ from "pip install virtualenv" ? Feb 4, 2017 at 16:52
  • pip (provided by python-pip in the default Ubuntu repositories) is an alternative Python package installer. It integrates with virtualenv, doesn't do partial installs, and can install from version control repositories. pip can also do either global installs using sudo pip or local installs inside virtualenv as a non-root user. Global installs with pip do not always install to the same directory as normal installations using apt in Ubuntu do. The --reinstall option was included in the answer to repair pip in case the python-pip package was already installed
    – karel
    Feb 5, 2017 at 0:01
0

As told here, you should use

sudo apt install python3-venv

to install the command and

python3.6 -m venv sample

to create a virtual environment named sample.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .