Why do I need to use pip3 but not pip

Peter Otten __peter__ at web.de
Sat Mar 30 05:56:38 EDT 2019


Arup Rakshit wrote:

> Hello All,
> 
> Thanks I got it now.
> 
> One related question: Can I use pip3 for example to install packages
> project specific, but not globally? So that when I delete the project, all
> of them gone also from my disk.

For that you can create a "virtual environment":

$ python3 -m venv foo
$ cd foo
$ . bin/activate

Once you have activated it you can use 'pip' and 'python' to invoke the 
versions attached to the virtual environment:

(foo) $ pip install example
Downloading/unpacking example
  Downloading example-0.1.0.tar.gz
  Running setup.py (path:/home/petto/foo/build/example/setup.py) egg_info 
for package example
    
Downloading/unpacking six (from example)
  Downloading six-1.12.0-py2.py3-none-any.whl
Installing collected packages: example, six
  Running setup.py install for example
    
Successfully installed example six
Cleaning up...
(foo) $ python
Python 3.4.3 (default, Nov 12 2018, 22:25:49) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import example
>>>

Let's get rid of it now:

(foo) $ deactivate
$ cd ..
$ rm -r foo  # everything should be gone





More information about the Python-list mailing list