我在 Arch linux 上,直到最近我犯了使用 pip 全局安装东西的错误。我试图删除所有与 pacman 未跟踪的 python 相关的内容。然后我删除了点子。
我知道 pip 的 --user 标志,但最后我使用相同的一堆基本包,我宁愿使用我的包管理器全局安装它们。
为了调试一些代码,我最近需要调试符号来引导我自己编译 python。之后,我使用 pacman 重新安装了它。
目前安装了 python2 和 3,而python
指向 v3。
如果我启动 REPL 并运行,help("modules")
我会得到:
>>> help("modules")
Please wait a moment while I gather a list of all available modules...
/usr/lib/python3.9/site-packages/IPython/kernel/__init__.py:12: ShimWarning: The `IPython.kernel` package has been deprecated since IPython 4.0.You should import from ipykernel or jupyter_client instead.
warn("The `IPython.kernel` package has been deprecated since IPython 4.0."
/usr/lib/python3.9/site-packages/lutris/gui/dialogs/__init__.py:10: PyGIWarning: Gtk was imported without specifying a version first. Use gi.require_version('Gtk', '3.0') before import to ensure that the right version gets loaded.
from gi.repository import GObject, Gtk, WebKit2, GLib
/usr/lib/python3.9/pkgutil.py:108: VisibleDeprecationWarning: zmq.eventloop.minitornado is deprecated in pyzmq 14.0 and will be removed.
Install tornado itself to use zmq with the tornado IOLoop.
yield from walk_packages(path, info.name+'.', onerror)
然后是模块列表,包括matplotlib
和matplotlib_inline
。
如果我尝试在 REPL 中导入它,我会得到:
Python 3.9.5 (default, May 24 2021, 12:50:35)
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/pascal/matplotlib.py", line 1, in <module>
import matplotlib.path as mpath
ModuleNotFoundError: No module named 'matplotlib.path'; 'matplotlib' is not a package
现在在写这篇文章时,当我在我的主目录中打开 REPL 时,我确实能够导入它一次,但我无法重现它。
此外还/usr/lib/python3.9/site-packages
包含
matplotlib/
matplotlib_inline/
matplotlib-3.4.1-py3.9.egg-info/
matplotlib_inline-0.1.2-py3.9.egg-info/
matplotlib-3.4.1-py3.9-nspkg.pth
并pacman -Q
列出
python-matplotlib 3.4.1-2
python-matplotlib-inline 0.1.2-1
搜索路径(在 REPL 中运行)也是:
>>> import sys
>>> sys.path
['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/home/<user>/.local/lib/python3.9/site-packages', '/usr/lib/python3.9/site-packages']