Search code examples
pythonxampppymysql

XAMPP and PyMySQL not integrating correctly


I am running XAMPP control panel 3.2.2 in order to have Apache and MySQL hosted, and I have correctly imported PyMySQL and cgi, which I have verified to be installed.

However, when I try and run a test script to make sure that everything is working together, it prints part of the program correctly, but not the other stuff. Images attached.

How do I fix this? I have tried Googling solutions but nothing to solve it has come up, and the python.exe location is definitely correct.

Modules verified

Program displayed

Test program

XAMPP running


Solution

  • Alright I fixed it, here is how I did it for anyone looking at this question:

    1. Open the Apache httpd.conf configuration file from XAMPP
    2. Locate the AddHandler block of code using CTRL-F
    3. Where it says

      AddHandler cgi-script .cgi .pl .asp
      

      Add .py to the end of the list so it instead becomes:

      AddHandler cgi-script .cgi .pl .asp .py
      
    4. Save the file with .py appended onto it

    5. Restart XAMPP and then launch the file from a web browser, where it should be working