页次: 1
突然发现pip出现问题,pip是指向pip3的符号链接,pip2可以正常使用。
报错如下:
python -m pip --version
Traceback (most recent call last):
File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/buding/.local/lib/python3.9/site-packages/pip/__main__.py", line 29, in <module>
from pip._internal.cli.main import main as _main
File "/home/buding/.local/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/home/buding/.local/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/home/buding/.local/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/home/buding/.local/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "/home/buding/.local/lib/python3.9/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "/home/buding/.local/lib/python3.9/site-packages/pip/_internal/configuration.py", line 21, in <module>
from pip._internal.exceptions import (
File "/home/buding/.local/lib/python3.9/site-packages/pip/_internal/exceptions.py", line 7, in <module>
from pip._vendor.pkg_resources import Distribution
File "/home/buding/.local/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3252, in <module>
def _initialize_master_working_set():
File "/home/buding/.local/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3235, in _call_aside
f(*args, **kwargs)
File "/home/buding/.local/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3277, in _initialize_master_working_set
tuple(
File "/home/buding/.local/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3278, in <genexpr>
dist.activate(replace=False)
File "/home/buding/.local/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2785, in activate
declare_namespace(pkg)
File "/home/buding/.local/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2284, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/buding/.local/lib/python3.9/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2217, in _handle_ns
loader.load_module(packageName)
File "/usr/lib/python3.9/site-packages/pygoogle/google.py", line 113
print """PyGoogle %(__version__)s
^
SyntaxError: invalid syntax
最近编辑记录 布丁酱 (2021-07-23 12:09:12)
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
你这个 pygoogle 哪里来的?你是 sudo pip 了还是用了奇怪的第三方包?自己清理一下吧。
离线
sudo pip和pip都报错了。
还没法卸载python-pip或者用pip uninstall pip卸载,前者是依赖问题,后者是python报错。
跑了下get-pip.py也报错。
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
sudo pip uninstall pygoogle ─╯
Traceback (most recent call last):
File "/usr/bin/pip", line 33, in <module>
sys.exit(load_entry_point('pip==20.3.4', 'console_scripts', 'pip')())
File "/usr/bin/pip", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/lib/python3.9/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/usr/lib/python3.9/site-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3.9/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3.9/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3.9/site-packages/pip/_internal/cli/cmdoptions.py", line 25, in <module>
from pip._internal.cli.progress_bars import BAR_TYPES
File "/usr/lib/python3.9/site-packages/pip/_internal/cli/progress_bars.py", line 12, in <module>
from pip._internal.utils.logging import get_indentation
File "/usr/lib/python3.9/site-packages/pip/_internal/utils/logging.py", line 18, in <module>
from pip._internal.utils.misc import ensure_dir
File "/usr/lib/python3.9/site-packages/pip/_internal/utils/misc.py", line 34, in <module>
from pip._internal.locations import get_major_minor_version, site_packages, user_site
File "/usr/lib/python3.9/site-packages/pip/_internal/locations/__init__.py", line 9, in <module>
from . import _distutils, _sysconfig
File "/usr/lib/python3.9/site-packages/pip/_internal/locations/_sysconfig.py", line 8, in <module>
from pip._internal.exceptions import InvalidSchemeCombination, UserInstallationInvalid
ImportError: cannot import name 'InvalidSchemeCombination' from 'pip._internal.exceptions' (/usr/lib/python3.9/site-packages/pip/_internal/exceptions.py)
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
别 sudo pip 了,直接去把文件删掉吧。以后别再 sudo pip 了,会弄坏的。
离线
去删那个site-package下的pip文件夹吗?
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
已解决,方法是直接将/usr/lib/python3.9命名为/usr/lib/python3.9.bak,然后重新安装python3和python-pip,此时pip直接可以使用,sudo pip会报错,使用sudo python3 get-pip.py,安装完成后,sudo pip也可以使用。
切记,使用yay -Qi python-pip命令确定一下对python-pip的依赖项,然后重新安装这些软件。
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
最后将/usr/lib/python3.9.bak重新命名为/usr/lib/python3.9,不要忘记!!!
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
方法过于暴力,不建议学习,除非做好了大修系统的准备。
最近编辑记录 布丁酱 (2021-07-22 17:19:46)
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
linux下pip一般是不允许以root运行的,可能会覆盖掉系统的文件,导致系统出错。
应该使用pip install --user *这种方式,将python模块安装到用户本身目录下(~/.local/lib/python*/)。
离线
对的,最好不自己进行pip install pip --upgrade,直接由包管理器管理比较好
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
官方对于使用get-pip.py的红框警告……
https://packaging.python.org/tutorials/ … mmand-line
离线
yay -Qe > installed.txt
yay -S `awk '{print $1}' installed.txt`
重装所有软件小技巧,尤其是环境出现问题时必备。
最后一步最好重装所有软件。
最近编辑记录 布丁酱 (2021-07-23 12:10:10)
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
自己更新pip应该没问题,我试了一下会默认安装到家目录。但是家目录下的.local/bin一般都不在path里……
最近编辑记录 xtricman (2021-07-24 00:11:28)
反社会,精神极其不稳定,随时可能炸碎身边所有人
离线
我的貌似还好
pip -V
pip 21.1.3 from /home/buding/.local/lib/python3.9/site-packages/pip (python 3.9)
sudo pip -V pip 21.1.3 from /usr/lib/python3.9/site-packages/pip (python 3.9)
布丁酱是菜鸡,没毛病,他是菜鸡:)
离线
页次: 1