Tentando instalar o discord.py, mas acabam com erros de permissão

0

Eu apenas mudei meu sistema operacional para o Ubuntu 16.04 (pela primeira vez usando linux).

Eu consegui instalar o Python 3.6 seguindo este guia: link

E eu instalei o pip seguindo a resposta encontrada neste encadeamento de estouro de pilha: link

Tudo funcionou como um encanto, no entanto, quando tento instalar o módulo discord.py usando python3.6 -m pip install -U discord.py , recebi um erro de permissão em tudo que ele tenta instalar.

Collecting discord.py
Collecting aiohttp<1.1.0,>=1.0.0 (from discord.py)
Collecting websockets<4.0,>=3.1 (from discord.py)
  Using cached websockets-3.4-cp36-cp36m-manylinux1_x86_64.whl
Collecting chardet (from aiohttp<1.1.0,>=1.0.0->discord.py)
  Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting multidict>=2.0 (from aiohttp<1.1.0,>=1.0.0->discord.py)
  Using cached multidict-3.1.3-cp36-cp36m-manylinux1_x86_64.whl
Collecting async-timeout (from aiohttp<1.1.0,>=1.0.0->discord.py)
  Using cached async_timeout-1.3.0-py3-none-any.whl
Installing collected packages: chardet, multidict, async-timeout, aiohttp,    websockets, discord.py
  Found existing installation: chardet 2.3.0
    Uninstalling chardet-2.3.0:
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3.6/shutil.py", line 544, in move
    os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3/dist- packages/chardet' -> '/tmp/pip-kssx4kah-uninstall/usr/lib/python3/dist- packages/chardet'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/pip/basecommand.py", line    215, in main
status = self.run(options, args)
  File "/usr/local/lib/python3.6/dist-packages/pip/commands/install.py",  line 342, in run
    prefix=options.prefix_path,
  File "/usr/local/lib/python3.6/dist-packages/pip/req/req_set.py", line  778, in install
    requirement.uninstall(auto_confirm=True)
  File "/usr/local/lib/python3.6/dist-packages/pip/req/req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/usr/local/lib/python3.6/dist-packages/pip/req/req_uninstall.py", line 115, in remove
   renames(path, new_path)
  File "/usr/local/lib/python3.6/dist-packages/pip/utils/__init__.py",    line 267, in renames
    shutil.move(old, new)
  File "/usr/lib/python3.6/shutil.py", line 556, in move
    rmtree(src)
  File "/usr/lib/python3.6/shutil.py", line 480, in rmtree
_    rmtree_safe_fd(fd, path, onerror)
  File "/usr/lib/python3.6/shutil.py", line 438, in _rmtree_safe_fd
    onerror(os.unlink, fullname, sys.exc_info())
  File "/usr/lib/python3.6/shutil.py", line 436, in _rmtree_safe_fd
    os.unlink(name, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'jpcntx.py'

Esta é apenas uma das mensagens de erro que recebo. Também obtenho outras como

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

e

PermissionError: [Errno 13] Permission denied: /usr/local/lib/python3.6/dist-packages/async_timeout

bem como

PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/multidict-3.1.3.dist-info'
    
por Varma Kafo 09.09.2017 / 13:20

1 resposta

0

Por favor, reserve um tempo para ler um pouco sobre como o Ubuntu e o linux como um todo funcionam, esse comando deveria ter sido:

sudo -H pip install  <package_name>

Por favor, note algumas coisas:

  1. Se você usar pip --version ou pip3 --version , verá a versão do python com o comando pip :

    pip 9.0.1 from /usr/local/lib/python3.5/dist-packages (python 3.5)
    
  2. Se você fizer pip2 --version , veremos python 2.* :

    pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
    
  3. O Python já existe, por isso é necessário reinstalá-lo.

  4. No Ubuntu pip e pip3 use python 3.* , mas pip2 usa python 2.*

Importante:

-H, --set-home

             Request that the security policy set the HOME environment variable to the home directory specified by the target user's password database
             entry.  Depending on the policy, this may be the default behavior.
    
por George Udosen 09.09.2017 / 13:47