为什么 mechanize 无法通过 pip 在 RPi 上正确安装? (蟒蛇3.9)

问题描述 投票:0回答:3

我无法在 virtualenv 中使用 Debian Bullseye、python 3.9 在 Raspberry Pi(即 ARM 芯片)上成功安装软件包“mechanize”。

当我查看 virtualenv 的 sitepackages 文件夹时,确实 mechanize 包只有

.dist-info
文件,但没有
mechanize.py
文件或
mechanize
包文件夹。见下文。

问题:我是否忽略了什么?

详情(一):使用pip安装mechanize

(venvtest) pi@mango:~/MyProject/myproj $ pip --version
pip 20.3.4 from /home/pi/MyProject/myproj/venvtest/lib/python3.9/site-packages/pip (python 3.9)

(venvtest) pi@mango:~/MyProject/myproj $ pip install mechanize
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting mechanize
Using cached https://www.piwheels.org/simple/mechanize/mechanize-0.4.8-py2.py3-none-any.whl (5.1 kB)
Requirement already satisfied: html5lib>=0.999999999 in /home/pi/MyProject/myproj/venvtest/lib/python3.9/site-packages (from mechanize) (1.1)
Requirement already satisfied: webencodings in /home/pi/MyProject/myproj/venvtest/lib/python3.9/site-packages (from html5lib>=0.999999999->mechanize) (0.5.1)
Requirement already satisfied: six>=1.9 in /home/pi/MyProject/myproj/venvtest/lib/python3.9/site-packages (from html5lib>=0.999999999->mechanize) (1.16.0)
Installing collected packages: mechanize
Successfully installed mechanize-0.4.8


(venvtest) pi@mango:~/MyProject/myproj $ pip list
Package       Version
------------- -------
html5lib      1.1
mechanize     0.4.8
pip           20.3.4
pkg-resources 0.0.0
setuptools    44.1.1
six           1.16.0
webencodings  0.5.1
wheel         0.34.2

详细信息(2):sitelibs 中缺少包文件夹

(venvtest) pi@mango:~/MyProject/myproj/ $ ls venvtest/lib/python3.9/site-packages
easy_install.py            pip-20.3.4.dist-info            __pycache__                   six.py                        wheel
html5lib                   pip-20.3.4.virtualenv           setuptools                    _virtualenv.pth               wheel-0.34.2.dist-info
html5lib-1.1.dist-info     pkg_resources                   setuptools-44.1.1.dist-info   _virtualenv.py                wheel-0.34.2.virtualenv
mechanize-0.4.8.dist-info  pkg_resources-0.0.0.dist-info   setuptools-44.1.1.virtualenv  webencodings
pip                        pkg_resources-0.0.0.virtualenv  six-1.16.0.dist-info          webencodings-0.5.1.dist-info

详情(3):因此导入机械化不起作用

(venvtest) pi@mango:~/MyProject/myproj $ python
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mechanize
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mechanize'
>>> exit()
python raspberry-pi importerror mechanize
3个回答
1
投票

这似乎是 0.4.8 版本的问题。安装 0.4.7 版本效果很好:

pip install mechanize==0.4.7

可见:

(venvtest) pi@mango:~/MyProj/myproj $ python
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import mechanize
>>> print(mechanize.__version__)
(0, 4, 7, None, None)

我已经在 mechanize github 存储库开了一张票:https://github.com/python-mechanize/mechanize/issues/76



0
投票

“sudo pip3 安装机械化” 为我工作

© www.soinside.com 2019 - 2024. All rights reserved.