PS E:\Python> pip index versions itsdangerous WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning. itsdangerous (2.1.2) Available versions: 2.1.2, 2.1.1, 2.1.0, 2.0.1, 2.0.0, 1.1.0, 0.24, 0.23, 0.22, 0.21, 0.20, 0.19, 0.18, 0.17, 0.16, 0.15, 0.14, 0.13, 0.12, 0.11, 0.10, 0.9.1, 0.9 INSTALLED: 2.1.2 LATEST: 2.1.2
2.安装指定版本,比如 1.1.0:
1 2 3 4 5 6 7 8 9 10
PS E:\Python> pip install itsdangerous==1.1.0 Defaulting to user installation because normal site-packages is not writeable Collecting itsdangerous==1.1.0 Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB) Installing collected packages: itsdangerous Attempting uninstall: itsdangerous Found existing installation: itsdangerous 2.1.2 Uninstalling itsdangerous-2.1.2: Successfully uninstalled itsdangerous-2.1.2 Successfully installed itsdangerous-1.1.0
× 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.11/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.
解决方法:
方法一:常规解决方法
1.先查看下本地使用的 pip 对应的 python 版本:
1 2
leazhi@ubuntu2310:/usr/lib/python3$ pip --version pip 23.2 from /usr/lib/python3/dist-packages/pip (python 3.11)
leazhi@ubuntu2210:/data/gitlab/hexo$ pip install django Defaulting to user installation because normal site-packages is not writeable Collecting django Obtaining dependency information for django from https://files.pythonhosted.org/packages/b9/45/707dfc56f381222c1c798503546cb390934ab246fc45b5051ef66e31099c/Django-4.2.6-py3-none-any.whl.metadata Downloading Django-4.2.6-py3-none-any.whl.metadata (4.1 kB) Collecting asgiref<4,>=3.6.0 (from django) Obtaining dependency information for asgiref<4,>=3.6.0 from https://files.pythonhosted.org/packages/9b/80/b9051a4a07ad231558fcd8ffc89232711b4e618c15cb7a392a17384bbeef/asgiref-3.7.2-py3-none-any.whl.metadata Downloading asgiref-3.7.2-py3-none-any.whl.metadata (9.2 kB) Collecting sqlparse>=0.3.1 (from django) Downloading sqlparse-0.4.4-py3-none-any.whl (41 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.2/41.2 kB 259.1 kB/s eta 0:00:00 Downloading Django-4.2.6-py3-none-any.whl (8.0 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.0/8.0 MB 1.0 MB/s eta 0:00:00 Downloading asgiref-3.7.2-py3-none-any.whl (24 kB) Installing collected packages: sqlparse, asgiref, django WARNING: The script sqlformat is installed in'/home/leazhi/.local/bin'which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: The script django-admin is installed in'/home/leazhi/.local/bin'which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed asgiref-3.7.2 django-4.2.6 sqlparse-0.4.4