AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / ubuntu / Perguntas / 1538953
Accepted
matej
matej
Asked: 2025-01-23 07:00:51 +0800 CST2025-01-23 07:00:51 +0800 CST 2025-01-23 07:00:51 +0800 CST

existe uma maneira de usar python com pacotes adicionais no Ubuntu?

  • 772

Eu gostaria de usar python no Ubuntu, mas preciso usar pacotes adicionais que não são instalados por padrão. Existe uma maneira de fazer isso? Até agora parece muito frustrante, já que não devo instalar pacotes adicionais pelo pip3 'global', mas, por outro lado, as versões 'venv' não estão funcionando.

Preciso de um pacote 'keyring' e 'pycryptodome'. Tenho uma instalação nova do Ubuntu 24.04. Quando tento:

$ pip3 install pycryptodome

Recebo este erro:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
user:~$ 

Então, acho que não devo instalar pacotes 'system-wide'. Então, criei um .venv e instalei o pacote pycryptodome. Mas então não posso usar o pacote 'keyring' naquele .venv:

user:~$ python3 -m venv .venv
user:~$ source .venv/bin/activate
(.venv) catchman:~$ pip3 install keyring
Collecting keyring
  Using cached keyring-25.6.0-py3-none-any.whl.metadata (20 kB)
Collecting SecretStorage>=3.2 (from keyring)
  Using cached SecretStorage-3.3.3-py3-none-any.whl.metadata (4.0 kB)
Collecting jeepney>=0.4.2 (from keyring)
  Using cached jeepney-0.8.0-py3-none-any.whl.metadata (1.3 kB)
Collecting jaraco.classes (from keyring)
  Using cached jaraco.classes-3.4.0-py3-none-any.whl.metadata (2.6 kB)
Collecting jaraco.functools (from keyring)
  Using cached jaraco.functools-4.1.0-py3-none-any.whl.metadata (2.9 kB)
Collecting jaraco.context (from keyring)
  Using cached jaraco.context-6.0.1-py3-none-any.whl.metadata (4.1 kB)
Collecting cryptography>=2.0 (from SecretStorage>=3.2->keyring)
  Using cached cryptography-44.0.0-cp39-abi3-manylinux_2_28_x86_64.whl.metadata (5.7 kB)
Collecting more-itertools (from jaraco.classes->keyring)
  Using cached more_itertools-10.6.0-py3-none-any.whl.metadata (37 kB)
Collecting cffi>=1.12 (from cryptography>=2.0->SecretStorage>=3.2->keyring)
  Using cached cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (1.5 kB)
Collecting pycparser (from cffi>=1.12->cryptography>=2.0->SecretStorage>=3.2->keyring)
  Using cached pycparser-2.22-py3-none-any.whl.metadata (943 bytes)
Using cached keyring-25.6.0-py3-none-any.whl (39 kB)
Using cached jeepney-0.8.0-py3-none-any.whl (48 kB)
Using cached SecretStorage-3.3.3-py3-none-any.whl (15 kB)
Using cached jaraco.classes-3.4.0-py3-none-any.whl (6.8 kB)
Using cached jaraco.context-6.0.1-py3-none-any.whl (6.8 kB)
Using cached jaraco.functools-4.1.0-py3-none-any.whl (10 kB)
Using cached cryptography-44.0.0-cp39-abi3-manylinux_2_28_x86_64.whl (4.2 MB)
Using cached more_itertools-10.6.0-py3-none-any.whl (63 kB)
Using cached cffi-1.17.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (479 kB)
Using cached pycparser-2.22-py3-none-any.whl (117 kB)
Installing collected packages: pycparser, more-itertools, jeepney, jaraco.context, jaraco.functools, jaraco.classes, cffi, cryptography, SecretStorage, keyring
Successfully installed SecretStorage-3.3.3 cffi-1.17.1 cryptography-44.0.0 jaraco.classes-3.4.0 jaraco.context-6.0.1 jaraco.functools-4.1.0 jeepney-0.8.0 keyring-25.6.0 more-itertools-10.6.0 pycparser-2.22

(.venv) user:~$ python3
Python 3.12.3 (main, Jan 17 2025, 18:03:48) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keyring
>>> keyring.get_keyring().get_password('Chrome Keys', 'Chrome Safe Storage') == None
True

Por outro lado, o 'sistema' python pode fazer isso:

user:~$ python3
Python 3.12.3 (main, Jan 17 2025, 18:03:48) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import keyring
>>> len(keyring.get_keyring().get_password('Chrome Keys', 'Chrome Safe Storage'))
24

Então parece que preciso usar .venv, mas naquele ambiente virtual o pacote (keyring) não está funcionando e eu deveria usar os pacotes python do sistema. Mas quando eu os uso, não consigo instalar nenhum outro pacote. Tipo um Catch-22

O Ubuntu suporta algum desenvolvimento python utilizável? Ou como eu deveria fazer isso funcionar?

Aqui estão as informações do meu sistema (avise-me se precisar de mais):

user:~$ cat /etc/issue
Ubuntu 24.04.1 LTS \n \l
user:~$ uname -a
Linux ryzen 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec  5 13:09:44 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

user:~$ plasmashell --version
plasmashell 5.27.11

user:~$ kf5-config --version
Qt: 5.15.13
KDE Frameworks: 5.115.0
kf5-config: 1.0

user:~$ python3 --version
Python 3.12.3

user:~$ pip3 --version
pip 24.0 from /usr/lib/python3/dist-packages/pip (python 3.12)
24.04
  • 1 1 respostas
  • 9 Views

1 respostas

  • Voted
  1. Best Answer
    Thomas Ward
    2025-01-23T07:13:35+08:002025-01-23T07:13:35+08:00

    Supondo que pelo keyringpacote você quer dizer python3-keyringinstalado via APT, há um problema conhecido em que pacotes de todo o sistema não são importados por padrão na venvgeração por padrão. Ou seja, seu venvé gerado apenas com pipmódulos extras. A maneira mais fácil de consertar isso é instalar python3-keyringno sistema via apte então gerar seu venvcom a inclusão adequada de pacotes de site de todo o sistema.

    Exclua seu venve gere novamente seu venv. Use este comando para gerar seu venv:

    python3 -m venv --system-site-packages .venv
    

    Agora, use seu venv. Você deve conseguir usar o keyringmódulo dentro do venvdepois.

    • 1

relate perguntas

  • Problemas ao instalar 24.04

  • Nenhum clique pode ser feito em todo o canto superior direito de um aplicativo maximizado no Ubuntu 24.04

  • Tenho uma dúvida sobre como baixar a versão do Ubuntu entre LTS e básica

  • 24.04 Textos LTS não aparecem até passar o mouse

  • A boutique de software não pode ser iniciada no Ubuntu24.04 LTS

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Existe um comando para listar todos os usuários? Também para adicionar, excluir, modificar usuários, no terminal?

    • 9 respostas
  • Marko Smith

    Como excluir um diretório não vazio no Terminal?

    • 4 respostas
  • Marko Smith

    Como descompactar um arquivo zip do Terminal?

    • 9 respostas
  • Marko Smith

    Como instalo um arquivo .deb por meio da linha de comando?

    • 11 respostas
  • Marko Smith

    Como instalo um arquivo .tar.gz (ou .tar.bz2)?

    • 14 respostas
  • Marko Smith

    Como listar todos os pacotes instalados

    • 24 respostas
  • Martin Hope
    Flimm Como posso usar o docker sem sudo? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    led-Zepp Como faço para salvar a saída do terminal em um arquivo? 2014-02-15 11:49:07 +0800 CST
  • Martin Hope
    ubuntu-nerd Como descompactar um arquivo zip do Terminal? 2011-12-11 20:37:54 +0800 CST
  • Martin Hope
    TheXed Como instalo um arquivo .deb por meio da linha de comando? 2011-05-07 09:40:28 +0800 CST
  • Martin Hope
    Ivan Como listar todos os pacotes instalados 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    David Barry Como determino o tamanho total de um diretório (pasta) na linha de comando? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher "Os seguintes pacotes foram retidos:" Por que e como resolvo isso? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford Como os PPAs podem ser removidos? 2010-07-30 01:09:42 +0800 CST

Hot tag

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve