0

I use this tutorial text as an example, there are others:

#!/usr/bin/python

import MySQLdb

If it produces the following result, then it means MySQLdb module is not installed −

Traceback (most recent call last):
   File "test.py", line 3, in <module>
      import MySQLdb
ImportError: No module named MySQLdb

To install MySQLdb module, use the following command −

For Ubuntu, use the following command -

$ sudo apt-get install python-pip python-dev libmysqlclient-dev

I have gone trough these steps, more or less as described above. Problem is that the subdirectory "python" does not exist under /usr/bin/ in my file system. I run Linux Mint 18.3. Python 2.7 seems to be the native version installed in Mint (used for several purposes), but I have also installed Python 3.6.4 and wish to use this for development purposes. Does anyone know in which directory I could expect to find MySQLdb? Since #!/usr/bin/python is non existent I wonder - has MySQLdb been properly installed? If it has, I have not after several efforts succeded in locating it.

Blue
  • 22,608
  • 7
  • 62
  • 92
  • Take a moment to read through the [editing help](//stackoverflow.com/editing-help) in the help center. Formatting on Stack Overflow is different than other sites. The better your post looks, the easier it is for others to read and understand it. – Blue Jan 25 '18 at 19:23
  • Possible duplicate of [How do I connect to a MySQL Database in Python?](https://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python) – fpietka Jan 25 '18 at 19:25
  • have you tried `sudo apt-get install python-mysqldb`? – noslenkwah Jan 25 '18 at 20:21
  • Yes I have. I tried it again, and was notified: python-mysqldb is already the newest version (1.3.7-1build2). – Per-Anton Rønning Jan 26 '18 at 08:23
  • Yes I have. I tried it again now,: python-mysqldb is already the newest version (1.3.7-1build2). Good to know that it is instralled, but there is no /usr/bin/python directory to import MySGLdb from. using sudo ls -aRl | grep MySQLdb gave hits, and 1 that makes sense: /usr/lib/python2.7/dist-packages/MySQLdb and there is a script (among others) called connections.py. BUT: #!/usr/lib/python3/dist-packages/MySQLdb import MySQLdb as mdb ModuleNotFoundError: No module named 'MySQLdb' i.e. no response in my simple test program. So I am grateful for further suggestions. – Per-Anton Rønning Jan 26 '18 at 08:47

0 Answers0