GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Fai `pip` Usa Python3.7 non predefinito?

So che questa è una domanda simile a quelle già poste molte volte, ma non riesco ancora a trovare una soluzione affidabile.
Ho molte versioni di Python installate sul mio Ubuntu 16.04, dalla 2.7 all'ultima 3.7.4.

L'impostazione predefinita è 2.7. So che non dovrei cambiare l'impostazione predefinita, perché altri l'hanno fatto e ha portato problemi seri come guasti al sistema.
Tuttavia, devo installare un software tramite pip:

pip install damn_software

che richiede python>=3.6

:~$ pip install damn_software
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

Collecting damn_software
Using cached https://files.pythonhosted.org/packages/cc/19/632db1d5095a35b08ba000d63e1ceffaf56c730dbd259f021e1fb7a75f68/damn_software-0.1.8.tar.gz
ERROR: Command errored out with exit status 1:
 command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qDPgIM/damn_software/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qDPgIM/damn_software/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
     cwd: /tmp/pip-install-qDPgIM/damn_software/
Complete output (1 lines):
ERROR: Python (3, 5) or later is required by software-helpers for damn_software
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Non so come ovviare a questo? Forse un collegamento simbolico?

MODIFICA :Ho dovuto eseguire i seguenti comandi aggiuntivi prima che l'installazione fosse completata:

python3.7 -m pip install --user --upgrade pip
python3.7 -m pip install your_packages
sudo apt install python3.7-dev 

Risposta accettata:

Basta eseguire l'interprete Python della versione desiderata, con pip come modulo da eseguire, come:

python3.6 -m pip install some_package

In questo modo puoi essere sicuro al 100% che l'interprete con cui avvii i tuoi script è lo stesso con cui gestisci i pacchetti pip. Non sono necessarie modifiche al sistema.

Il pip eseguibile non è comunque esattamente definito come una versione fissa, qualsiasi aggiornamento successivo probabilmente lo sovrascriverebbe di nuovo. Inoltre a volte si rompe per altri motivi come incompatibilità di versione comunque. Di solito non lo userei affatto direttamente, tranne forse quando ti trovi in ​​un venv (ambiente virtuale Python) dove è esattamente definito di cosa si tratta.

Correlati:problemi con GPU Nvidia e Ubuntu 16.04?
Ubuntu
  1. Come fare in modo che Startx usi Xinitrc alternativo?

  2. È possibile creare e utilizzare menu in Vim (basato su terminale)?

  3. Come fare in modo che Skype utilizzi Notify-osd?

  4. Uso del comando:`comando`?

  5. pip e pip3 - entrambi puntano a python3.5?

Come fare in modo che l'app Linux di Telegram utilizzi la cornice della finestra di sistema

Come usare e sfruttare al meglio il comando fusore in Linux

Come installare Pip su Ubuntu

Come fare buon uso del comando 'grep'

Come installare e utilizzare gli strumenti Python PIP su Ubuntu 20.04 LTS

Come fare in modo che i comandi in Mathematica 8 utilizzino tutti i core?