6

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.

AndreJ
77.3k5 gold badges89 silver badges164 bronze badges
asked Jul 25, 2014 at 18:32

5 Answers 5

7

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).

answered Jul 25, 2014 at 18:49
1
  • 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. Commented Jul 25, 2014 at 19:12
7

pip3 uninstall PyQt5 worked for me

answered Jun 29, 2020 at 13:56
0
4

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

answered Aug 3, 2020 at 8:18
2
  • Deleting C:\Users\user\AppData\Roaming\Python folder worked for me. Commented Oct 26, 2020 at 23:05
  • Useful tip. However, I had to use Anaconda also. Therefore , I am just renaming the folder Commented Jun 16, 2021 at 16:36
1

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.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Jun 21, 2017 at 1:12
1
  • 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. Commented Jun 21, 2017 at 14:45
0

for QGIS 3.22 below commands works

sudo -H pip3 uninstall PyQt5-sip

sudo -H pip3 uninstall PyQt5

sudo -H pip3 install sip

answered May 20 at 10:18

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.