/usr/local/lib/python3.5/dist-packages/pip/

cancella pip da lì e reinstallala con

|sudo apt install python3-pip In generale, puoi sempre ripartire da zero: https://packaging.python.org/tutorials/installing-packages/ If pip isn’t already installed, then first try to bootstrap it from the standard library: Unix/macOS python3 -m ensurepip --default-pip If pip isn’t already installed, then first try to bootstrap it from the standard library: python3 -m ensurepip --default-pip If that still doesn’t allow you to run python -m pip: Securely Download get-pip.py Run python get-pip.py. This will install or upgrade pip. Additionally, it will install setuptools and wheel if they’re not installed already. Insomma, se ne esce :-) |

Il 31/05/21 14:38, Valerio Pachera ha scritto:
Grazie per le risposte.
Avevo valutato (velocemente) se usare virtualenv o venv e la mia scelta era ricaduta sul primo perché ha alcune funzionalità in più, in particolare, paragonato a virtualenv https://virtualenv.pypa.io/en/latest/ <https://virtualenv.pypa.io/en/latest/> "cannot create virtual environments for arbitrarily installed python versions (and automatically discover these),"

Il vero problema che sto cercando di aggirare è questo (su ubuntu 16.04):

pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 12, in main
from pip._internal.utils.entrypoints import _wrapper
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/utils/entrypoints.py", line 4, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 58
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax

notare che avendo pip3 "rotto" di suo, non posso neanche usarlo per installare altri moduli nel virtual env.

Ho provato quindi ad installare una versione specifica di pip:
https://stackoverflow.com/questions/66212924/pip-sys-stderr-writeferror-exc-with-python-3-5 <https://stackoverflow.com/questions/66212924/pip-sys-stderr-writeferror-exc-with-python-3-5>

Ho installato
apt-get install python3-venv

e provato a creare e attivare il virtual env
python3 -m venv venv
source venv/bin/activate

Installo con successo i moduli che mi servono:
pip3 install htmlentities Jinja2 ldap3 python-zimbra six

eseguo il mio script e va in crisi su qualcosa relativo a Jinja2

./myscript.py -h
Traceback (most recent call last):
File "./myscript.py", line 7, in <module>
from jinja2 import Environment, FileSystemLoader
File "/opt/Custom/myscript/venv/lib/python3.5/site-packages/jinja2/__init__.py", line 5, in <module>
from .bccache import BytecodeCache as BytecodeCache
File "/opt/Custom/myscript/venv/lib/python3.5/site-packages/jinja2/bccache.py", line 61
self.code: t.Optional[CodeType] = None
^
SyntaxError: invalid syntax

Controllo la variabile d'ambiente

echo $PATH
/opt/Custom/ss-signatures/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

E qua credo proprio che l'interprete sia troppo vecchio.

_______________________________________________
Python mailing list
Python@lists.python.it
https://lists.python.it/mailman/listinfo/python
_______________________________________________
Python mailing list
Python@lists.python.it
https://lists.python.it/mailman/listinfo/python

Rispondere a