0

hope u can help me.

i have the problem that i cant use mechanize in Python. i really dont know why.

My python version is: Python 3.10.9

i just wrote this in a python file:

import mechanize

browser = mechanize.Browser()

and the Error is:

Traceback (most recent call last): File "C:\Users\Daniel\Desktop\stackoverflow.py", line 1, in import mechanize ModuleNotFoundError: No module named 'mechanize'

thanks guys!

before you ask, yes i installed the last version of mechanize on my windows computer like this:

C:\Users\Daniel>pip3 install mechanize
Requirement already satisfied: mechanize in c:\users\daniel\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (0.4.8)
Requirement already satisfied: html5lib>=0.999999999 in c:\users\daniel\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from mechanize) (1.1)
Requirement already satisfied: webencodings in c:\users\daniel\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from html5lib>=0.999999999->mechanize) (0.5.1)
Requirement already satisfied: six>=1.9 in c:\users\daniel\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages (from html5lib>=0.999999999->mechanize) (1.16.0)
Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
C.O.D.E
  • 1
  • 2
  • Does `pip3 --version` point to the same python as `where python3`? – Pranav Hosangadi Jan 06 '23 at 16:28
  • C:\Users\Daniel>pip3 --version pip 22.3.1 from C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip (python 3.10) – C.O.D.E Jan 06 '23 at 16:31
  • Are you using virtualenv? – drum Jan 06 '23 at 16:33
  • no, just my windows 10 computer – C.O.D.E Jan 06 '23 at 16:35
  • @PranavHosangadi no. The first one is "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\site-packages\pip" and the second one is: "C:\Users\Daniel\AppData\Local\Microsoft\WindowsApps\python3.exe" – C.O.D.E Jan 06 '23 at 16:41
  • There you go! Your `pip3` is installing packages to a different python installation than what runs when you do `python3`. This is why the better way of installing packages using pip is to do `python3 -m pip install ...`, which ensures that the same `python3` you use when you run a command is used to call `pip install ...` – Pranav Hosangadi Jan 06 '23 at 16:44
  • 1
    Does this answer your question? [PIP3 associated with the wrong python version](https://stackoverflow.com/questions/57645600/pip3-associated-with-the-wrong-python-version) (I know it's a Mac question and you're on Windows, but the solution is the same) – Pranav Hosangadi Jan 06 '23 at 16:46

0 Answers0