I recently installed QGIS 2.4, but Python does not load. I am running on a Windows 64 bit machine.

I receive the error message "Couldn't load SIP module Python support will be disabled".

Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: %1 is not a valid Win32 application.

I have another installation of Python at C:/Python27. It is the 32-bit version.

When I remove C:/Python27 folder, QGIS works fine, so there is some linkage between the new QGIS installation and the C:/Python27 python interpreter. I can't permanently delete C:/Python because I need it for other applications, so I am wondering if there are any suggestion as to how to fix this.

In a command window, type set > set.txt to get a list of all environment variables you have set. Your python installation may have set some values that QGIS does not like.

The PATH variable is save, because qgis.bat sets its own path variable, but PYTHONPATH or something else may be harmful.

Once you found a link to C:\Python27, go to the system properties and change the environment variable (not sure how the commands are in your language version).

• Thanks Andre, I deleted out the PYTHONPATH links and the problem was solved. Interestingly, when I added them back into a new PYTHONPATH, QGIS/Python still work. – user44796 Jul 25 '14 at 19:12

pip3 uninstall PyQt5 worked for me

In my case, it turns out to be a conflict of different versions of python. I uninstalled python 3.7 after I installed the latest python 3.8. Somehow QGIS was still using python 3.7. And the folder python 3.7 reminds in the directory C:\Users\user\AppData\Roaming\Python.

Problem solved by deleting the python 3.7 folder.

BTW, it is a case on Windows

• Deleting C:\Users\user\AppData\Roaming\Python folder worked for me. – Kadir Şahbaz Oct 26 '20 at 23:05
• Useful tip. However, I had to use Anaconda also. Therefore , I am just renaming the folder – addcolor Jun 16 at 16:36

Removing the PYTHONPATH environment variable as suggested above did not work in my case with QGIS 2.18.9 w/ GRASS x64 and python 2.7 on Win7. For some reason, I had to remove c:\python27 from my PATH (temporarily), and add the QGIS install python27 folder to my PYTHONPATH variable. Then QGIS 2.18.9 started up without this error. I was able to add c:\python27 back into my path and restart QGIS with no difficulty, and my python plugins are working again.

• I found a (possibly) better solution. There is a python-core.bat in C:\Program Files\QGIS 2.18\etc\ini that sets up the python environment variables. I just added a: set PYTHONPATH=%OSGEO4W_ROOT%\apps\Python27;%OSGEO4W_ROOT%\apps\Python27\Lib;%OSGEO4W_ROOT%\apps\Python27\Lib\site-packages;%PYTHONPATH%. I also added the %OSGEO4W_ROOT%\apps\Python27 directory to the PATH on the next line. – Heath Jun 21 '17 at 14:45