1

I have installed virtualenv using the command pip install virtualenv and it gave me this.

pip install virtualenv
Downloading/unpacking virtualenv
  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   0%   Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB):   0%    Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB): 1.8MB downloaded
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...

Now you can see that virtualenv is installed to confirm this i have tested like this,

 ubuntu@ubuntu  ~  which pip
/usr/bin/pip
 ubuntu@ubuntu  ~  which python
/usr/bin/python
 ubuntu@ubuntu  ~  which virtualenv
virtualenv not found
 ✘ ubuntu@ubuntu  ~  python --version
Python 2.7.12
ubuntu@ubuntu  ~  pip --version
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)

Now real problem is that i want to create a virtualenv i have entered command

virtualenv env --no-site-packages and it gave me error.

command not found: virtualenv

Any solutions to this problem.I have also using ubuntu -16 with all updates installed.

bfontaine
  • 18,169
  • 13
  • 73
  • 107
SaiKiran
  • 6,244
  • 11
  • 43
  • 76
  • The executable of `virtualenv` seems not to be in the load-path. Just reopening the terminal might already help, otherwise `pip show virtualenv` shows you the location that you can then add to your load-path. – Simon Fromme Dec 18 '16 at 18:07
  • 1
    `ubuntu@ubuntu  ~  pip show virtualenv --- Name: virtualenv Version: 15.1.0 Location: /home/ubuntu/.local/lib/python2.7/site-packages Requires: ubuntu@ubuntu  ~  virtualenv zsh: command not found: virtualenv ` – SaiKiran Dec 18 '16 at 18:07
  • What is the output of `echo $PATH`? – Simon Fromme Dec 18 '16 at 18:09
  • `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin` – SaiKiran Dec 18 '16 at 18:09
  • You should never install using `pip` in your Linux systems' python, you might break your system. Apart from that the current `pip` version is 9.0.1, that what you have there is outdated and insecure. See e.g. http://stackoverflow.com/a/30692103/1307905 on how to properly create and use `virtualenv` in a virtual env. – Anthon Dec 18 '16 at 18:17

1 Answers1

5

You should use your system's package manger to install it instead of pip. On Ubuntu, you can run:

apt-get install python-virtualenv

You will then see output from the 'which' command.

diametralpitch
  • 675
  • 3
  • 5
  • 1
    In addition to this correct answer: `/usr/bin/pip` could not install virtualenv into system directories because regular user "ubuntu" cannot write into `/usr/bin/`. Then virtualenv was installed into user install directory, so you can launch it as `/home/ubuntu/.local/bin/virtualenv`. Optionally, append `~/.local/bin` to `$PATH`. – void Dec 18 '16 at 20:59
  • This might work but should not be recommended. Installing this way gives you virtualenv 1.11. The current version of virtualenv is 15.1, which has many bug fixes, and works with a more modern versions of `pip` for further installs (with their own bug and security fixes). Since you can install virtualenv directly in a virtualenv without needing root prileges, the normal excuse that you should not litter your installation with non-tracked data doesn't hold. – Anthon Dec 19 '16 at 06:02
  • @Anthon it looks like 15.1 is available in the Ubuntu 16 repos http://packages.ubuntu.com/xenial/python/python-virtualenv – diametralpitch Dec 19 '16 at 07:22
  • Correction - 15.0.1 – diametralpitch Dec 19 '16 at 07:25