ModuleNotFoundError: No module named 'mysql' even when module is installed - python

I am fairly new to python and I am trying to write a script that would read and write to a mysql table. I have installed mysql-connector on python3 and I got the script working yesterday. It successfully read and wrote data to mysql. When I ran it today, this error came up. ModuleNotFoundError: No module named 'mysql'
I already checked the following things:
mysql-connector is installed
I don't have any user-defined module named mysql
not running on virtualenv
Does someone have any idea on what is happening?

check if mysql-connector is installed: python -m pip freeze. It is probably not listed. You can install it with:
pip install mysql-connector
or
python -m pip install mysql-connector

Related

I cannot install requests module on my computer

I get this error when I run my python project(I'm using python 3.10.5 on Windows 10):
ModuleNotFoundError: No module named 'requests'
Despite the fact that I do infact have the module installed. I also tried uninstalling it and installing it again, but that didn't work. I had a conflict on my other computer again with requests and installing discord.py, but I can't seem to get it to work here. I installed discord.py v2 using:
pip install -U git+https://github.com/Rapptz/discord.py
In Command Prompt Type: py -3 -m pip install requests
If it doesn't install, go to the given address and delete all the folders that say requests and upload again.

ModuleNotFoundError: No module named 'pyodbc' even though pyodbc is installed

I have installed pyodbc inside my virtual environment(venv). However when I try to import this package it throws ModuleNotFoundError: No module named 'pyodbc'.
Below is the screenshot of what happen when I run pip install pyodbc
also, I can see pyodbc is installed on venv with the output of pip freeze. Please help me resolve this issue so that I can use pyodbc module in my virtual environment.

No module named 'pyaudio'

I am writing a program in Python, But I got an error
ModuleNotFoundError: No module named 'pyaudio'
Then I tried
pipwin install pyaudio
It came out
Requirement already satisfied: PyAudio==0.2.11 from file:///C:/Users/JIE_0305/pipwin/PyAudio-0.2.11-cp37-cp37m-win_amd64.whl
but I run the program again, it still
ModuleNotFoundError: No module named 'pyaudio'
How can I solve the problem?
You could download the whl file and call it when installing, this might work, according to this post. In the post, you have the links to the site where you can download the whl file.
It is also stated that it might work with Python 3.6 and not 3.7, try changing your Python version to 3.6, if the other options give not result.
Another solution is uninstalling pyaudio, then connecting to your virtual environement and install again withing your venv. It might solve your problem.
Sometimes it happens that a library successfully installed might be related to a Python version which is different than the one you used when running the program. You should check this also, I mean check to which Python version the pyaudio library is related. Use the same Python version in order to run the program.
Try refreshing first with
pipwin refresh
If not use pip instead
pip install pyaudio --> python2
pip3 install pyaudio --> python3
Please try to use the pip command instead.
python3 -m pip install pyaudio # for python 3
or
python -m pip install pyaudio # for python 2 or lower

Getting error even the package is installed

I'm new learner. I installed openpyxl module. And I have it in my directory. But when I want to use it I get error :
"ModuleNotFoundError: No module named 'openpyxl'"
any help?
This type of errors (ModuleNotFoundError) is usually caused due to various versions of Python being installed on your system. If you have both Python 2 and 3 installed, use pip2 or pip3 to install your module.
pip2 install openpyxl # for python2
pip3 install openpyxl # for python3

ImportError: No module named mako.util when running airflow

I'm trying to follow the tutorial on here: http://pythonhosted.org/airflow/tutorial.html
but i'm using a mac, and so i had to install python via brew, which then comes with pip, which i used to install airflow. However, that didn't quite work either, so i then tried to create a virtualenv for which i tried to install airflow and it is still giving me this ImportError: No module named mako.util
not sure if it matters, but here's my setup:
(airflow) [davidtian: airflow]$ python --version
Python 2.7.12
(airflow) [davidtian: airflow]$ pip --version
pip 8.1.2 from /Users/someone/Desktop/blah/airflow/airflow/lib/python2.7/site-packages (python 2.7)
(airflow) [davidtian: airflow]$
How do i install this mako.util module?
Finally figured it out. after trying a bunch of things. for one, the python that comes with Mac apparently doesn't work very well. you have to brew install python instead. with that python, it comes with pip by default
i had to actually sudo pip uninstall airflow and then install it again.

Categories