2

I use command pip3 install ipython but getting these error may I need to install virtualenv ?

Exception:
Traceback (most recent call last):
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/home/saurabh/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib/python3.5/os.py", line 241, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/IPython'
Taku
  • 31,927
  • 11
  • 74
  • 85
sdevis
  • 31
  • 6
  • 2
    Please add `sudo`: `sudo pip3 install IPython` – cs95 Oct 06 '17 at 06:19
  • 4
    NO! Do **NOT** use `sudo` with `pip`. @cᴏʟᴅsᴘᴇᴇᴅ, I am actually surprised to hear such a thing from you. See [this](https://stackoverflow.com/questions/21055859/what-are-the-risks-of-running-sudo-pip) – adder Oct 06 '17 at 06:21
  • it works thanks @COLDSPEED – sdevis Oct 06 '17 at 06:22
  • 1
    Sudo pip is a very dangerous game to play. There are much safer ways around this issue that would have come up in a simple Google search. – Stuart Buckingham Oct 06 '17 at 06:25
  • @mentalita relax, it was for IPython, pretty trustworthy. – cs95 Oct 06 '17 at 07:22

2 Answers2

2

The error message reveals the problem: You don't have permission to write to the folder since /usr/... is a system folder.

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/IPython'

You need to use sudo to install globally or just install them using --user option which installs the package only for the current user and not for all:

pip install ipython --user

Or maybe a better option is to use a virtual environment which isolates packages for you.

Duc Filan
  • 6,769
  • 3
  • 21
  • 26
0

Whenever any permission issues/error are there during installation of any package always add sudo before your installation command. Hence command will be:

sudo pip3 install IPython
Duc Filan
  • 6,769
  • 3
  • 21
  • 26
Tanmay
  • 111
  • 1
  • 6