opencv installed, yet ModuleNotFoundError: No module named 'cv2'
Hello there,
Although I've installed everything, I am facing this problem; Quote:
Code:
mq15@BigBang:~$ uname -a |
You appear to have "pip3" connected to Python 3.8, but "python3" connected to Python 3.10
The output of "which -a pip3 python3" should confirm that. To install with pip into the expected Python version, use "python3 -m pip ..." instead of "pip3 ..." Or, if you want to run Python 3.8, you can use the absolute path which the above "which" statement reveals. |
Quote:
Code:
mq15@BigBang:~$ which -a pip3 python3 Code:
mq15@BigBang:~$ python3 -m pip install opencv-python Any help will be highly appreciated. |
Quote:
You also have Python 3.10 (without Pip) installed to /usr/local/bin, which is why it takes precedence when entering a non-absolute python3. Quote:
Code:
mq15@BigBang:~$ pip3 install opencv-python Quote:
Unless you have a specific identified need for a particular version, it's simplest to just stick with what's provided in your distro's software repositories, and not worry about new/shiny stuff until your distro includes that version in its repos. However, if you do have such a need, you probably want to look into pyenv which allows having multiple different versions installed, with specific versions for different projects. That way you can keep your distro's version as the default, but also use other versions for specific projects you might have, and pyenv will keep the python3 and pip3 commands in-sync. |
Quote:
In fact, I don't have any specific need for a particular version. I'm just learning some python coding. So, how should I know which version is provided in my distro's software repositories, and how to "stick" to that, in order to avoid the complaint; Quote:
|
Quote:
You can also check your distro's package management - e.g. for Mint (and other Debian-based systems) "apt info python3" and see what that says regarding version. To find out which package is responsible for a file, you can use dpkg, e.g: "dpkg -S /usr/bin/python3 /usr/bin/pip3 /usr/local/bin/python3" Quote:
To avoid doing that you'd need to remove the instance at "/usr/local/bin/python3" - how will depend on how it was installed - the above dpkg command will confirm if there's a known package involved, if not renaming the file to "/usr/local/bin/python3_unused" would probably work. |
Thank you very much boughtonp for bearing with me.
Quote:
Quote:
Quote:
Code:
mq15@BigBang:~$ dpkg -S /usr/bin/python3 /usr/bin/pip3 /usr/local/bin/python3 For option-2, renaming, I am not sure how to do it either. Please consider; Code:
mq15@BigBang:~$ rename /usr/local/bin/python3 /usr/local/bin/python3_unused |
Quote:
(There's still a potential risk of it breaking software installed by non-standard means, but you'd presumably know if you'd done that; either way keep a note that you've renamed it in case something crops up in future, but if you're not sure then it's probably fine.) Quote:
Also, to avoid typing the filename twice you can use shell expansions, e.g: "mv /usr/local/bin/python3{,_unused}" is equivalent to "mv /usr/local/bin/python3 /usr/local/bin/python3_unused". (If that gives a permission denied error you'll need to be root, using either su or sudo.) |
Thank very much dear boughtonp
Quote:
One more thing. May I remove the instance at /usr/local/bin/python3 like this; Quote:
Quote:
|
APT works with packages rather than files, so that isn't going to work.
You'd need to identify how it was installed so you can determine where it's dependencies were placed in order to purge it - was there a script that was executed and/or a tutorial followed to install that version? |
1 Attachment(s)
As far as I rememer, I downloaded Python-3.10.2.tgz from https://www.python.org/. Extracted Python-3.10.2.tgz. Found a file README.rst. And followed its build instructions.
Quote:
|
Hrm, the Python configure script is several thousands of lines long(!), yet doesn't appear to include an "uninstall" option. :/
I guess cd into that directory and see if "grep -i uninstall ./*" brings up anything? (Probably not.) The configure script generates a file named "Makefile", which is what the "make" command uses - it's possible that despite the configure script being obscenely long the generated file might still be short, so even without an uninstall option it might be possible to reverse the install option - open it with a text editor to have a look, and locate the install part - hopefully there's only a handful of commands copying files, in which case those can then be undone to manually uninstall it. |
All times are GMT -5. The time now is 09:46 PM. |