I can’t get to successfully install the package ‘mechanize’ on a Raspberry Pi (so, ARM chip) with Debian Bullseye, python 3.9 in a virtualenv.
When I look in the virtualenv’s sitepackages folder, indeed the mechanize package only has .dist-info
file, but not a mechanize.py
file or mechanize
package folder. See below.
Question: Am I overlooking something?
Details (1): Installing mechanize with pip
JavaScript
x
26
26
1
(venvtest) pi@mango:~/MyProject/myproj $ pip --version
2
pip 20.3.4 from /home/pi/MyProject/myproj/venvtest/lib/python3.9/site-packages/pip (python 3.9)
3
4
(venvtest) pi@mango:~/MyProject/myproj $ pip install mechanize
5
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
6
Collecting mechanize
7
Using cached https://www.piwheels.org/simple/mechanize/mechanize-0.4.8-py2.py3-none-any.whl (5.1 kB)
8
Requirement already satisfied: html5lib>=0.999999999 in /home/pi/MyProject/myproj/venvtest/lib/python3.9/site-packages (from mechanize) (1.1)
9
Requirement already satisfied: webencodings in /home/pi/MyProject/myproj/venvtest/lib/python3.9/site-packages (from html5lib>=0.999999999->mechanize) (0.5.1)
10
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)
11
Installing collected packages: mechanize
12
Successfully installed mechanize-0.4.8
13
14
15
(venvtest) pi@mango:~/MyProject/myproj $ pip list
16
Package Version
17
------------- -------
18
html5lib 1.1
19
mechanize 0.4.8
20
pip 20.3.4
21
pkg-resources 0.0.0
22
setuptools 44.1.1
23
six 1.16.0
24
webencodings 0.5.1
25
wheel 0.34.2
26
Details (2): Package folder missing in sitelibs
JavaScript
1
7
1
(venvtest) pi@mango:~/MyProject/myproj/ $ ls venvtest/lib/python3.9/site-packages
2
easy_install.py pip-20.3.4.dist-info __pycache__ six.py wheel
3
html5lib pip-20.3.4.virtualenv setuptools _virtualenv.pth wheel-0.34.2.dist-info
4
html5lib-1.1.dist-info pkg_resources setuptools-44.1.1.dist-info _virtualenv.py wheel-0.34.2.virtualenv
5
mechanize-0.4.8.dist-info pkg_resources-0.0.0.dist-info setuptools-44.1.1.virtualenv webencodings
6
pip pkg_resources-0.0.0.virtualenv six-1.16.0.dist-info webencodings-0.5.1.dist-info
7
Details (3): As a consequence, importing mechanize doesn’t work
JavaScript
1
10
10
1
(venvtest) pi@mango:~/MyProject/myproj $ python
2
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
3
[GCC 10.2.1 20210110] on linux
4
Type "help", "copyright", "credits" or "license" for more information.
5
>>> import mechanize
6
Traceback (most recent call last):
7
File "<stdin>", line 1, in <module>
8
ModuleNotFoundError: No module named 'mechanize'
9
>>> exit()
10
Advertisement
Answer
It appears to be an issue with version 0.4.8. Installing version 0.4.7 works fine:
JavaScript
1
2
1
pip install mechanize==0.4.7
2
as can be seen:
JavaScript
1
8
1
(venvtest) pi@mango:~/MyProj/myproj $ python
2
Python 3.9.2 (default, Mar 12 2021, 04:06:34)
3
[GCC 10.2.1 20210110] on linux
4
Type "help", "copyright", "credits" or "license" for more information.
5
>>> import mechanize
6
>>> print(mechanize.__version__)
7
(0, 4, 7, None, None)
8
I’ve opened a ticket at the mechanize github repository: https://github.com/python-mechanize/mechanize/issues/76