skip to Main Content

I’m trying to install the MySQLdb package for python3, because I need to use mysql for a project I’m currently doing.
But I can’t get that package and work with it

I have tried the following things:

When I try to import it, I get this error:

python3 Get_Acess_and_Refresh_Tokens.py 
Traceback (most recent call last):
  File "/home/*****/Desktop/*****/Get_Acess_and_Refresh_Tokens.py", line 6, in <module>
    from MySQLdb import _mysql
ModuleNotFoundError: No module named 'MySQLdb'

When I try to install python-mysqldb I get this message:

~$ sudo apt-get install python-mysqldb
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python-mysqldb is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python-mysqldb' has no installation candidate`

When I try to apt-get update I get this: I have just copied some errors because it detects them as spam

$ sudo apt-get update
Err:2 http://es.archive.ubuntu.com/ubuntu jammy InRelease
  Temporary failure resolving 'es.archive.ubuntu.com'

Reading package lists... Done
W: Failed to fetch http://es.archive.ubuntu.com/ubuntu/dists/jammy/InRelease  Temporary failure resolving 'es.archive.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

Edit: This last part I have solved with this post: https://askubuntu.com/questions/91543/apt-get-update-fails-to-fetch-files-temporary-failure-resolving-error
But the problem continues with the same result

Anyone know what I am doing wrong and any solution/alternative to deal with it?

Thanks in advance

2

Answers


  1. Chosen as BEST ANSWER

    I have read that mysqldb is not available in python3, and I couldn't install it in any way, therefore I switch to pymysql who seems to have the same behaviour. It has solved my problem.


  2. This happens when you try to install a package about which APT does not have any idea. When you add software sources, you need to do an apt-get update so that your system APT’s database is updated with all the packages on the repositories listed in the software sources lists.

    Then when you try to install any package, APT checks the package name in its database, finds it and checks the name of the repository from where it got it. It then downloads the package from that repository.

    This means of all the repositories listed in your software sources, none of them have the package named munin-memcached. I checked again and it is not available in official Ubuntu repositories.

    After a bit of googling, I found that it is available in this PPA: chris-lea/munin-plugins

    Add this PPA and install the packages at your own risk. I do not know this person.

    To add the PPA, issue the below command:

    sudo add-apt-repository ppa:chris-lea/munin-plugins

    To install package munin-memcached, issue the below command:

    sudo apt-get update && sudo apt-get install munin-memcached

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search