I am an experienced Python developer, but new to QGIS. I just installed QGIS 2.18.4 and am getting the following error message when I start it.

Couldn't load QGIS utils.
Python support will be disabled.

Traceback (most recent call last):
  File "", line 1, in 
  File "C:/PROGRA~1/QGIS2~1.18/apps/qgis/./python\qgis\utils.py", line 21, in 
  File "C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\future\standard_library\__init__.py", line 465, in install_aliases
    from future.backports.urllib import request
  File "C:\PROGRA~1\QGIS2~1.18\apps\Python27\lib\site-packages\future\backports\urllib\request.py", line 93, in 
    import hashlib
  File "C:\Python27\Lib\hashlib.py", line 138, in 
AttributeError: 'module' object has no attribute 'openssl_md_meth_names'

Python version:
2.7.5 (default, May 15 2013, 22:44:16) [MSC v.1500 64 bit (AMD64)]

QGIS version:
2.18.4 'Las Palmas', 59c1d21

Python path:

[Rest of my preexisting PYTHONPATH],


I already had Python 2.7.12 installed on my machine before installing QGIS; it seems to have come with a prepackaged version of Python, 2.7.5. It appears to be modifying my PYTHONPATH environment variable, adding new directories to it on both sides. The problem is that because it adds C:\Program Files\QGIS 2.18\apps\Python27\lib to the end of the path, after C:\Python27\Lib, it finds the Python 2.7.12 version of hashlib first, which apparently contains code the rest of QGIS' Python distribution can't handle (like the line causing this AttributeError). I scanned the Settings menu and don't see anything about how the PYTHONPATH is constructed. Is it normal for QGIS to not play nice with preexisting Python installations?


Python path issues can be frustrating try:

  • Uninstall previous Python versions and old QGIS files
  • ensure you're installing the appropriate version of either 32-bit or 64-bit
  • do a fresh install of QGIS
  • ensure your python path is pointing to the QGIS version
  • double check the ordering of your PYTHONPATH if you still have issues.
  • So do I have just use QGIS' Python installation and effectively downgrade to 2.7.5? I can see the ordering of the PYTHONPATH that would work; I just don't have any control over that order since it is set up by QGIS on startup. – David Pitchford Mar 20 '17 at 16:53

QGIS is invoked by starting a qgis.bat file in C:\Program Files\QGIS 2.18\bin, which does the required environment settings to run QGIS in a separate file o4w_env.bat. That file calls C:\Program Files\QGIS 2.18\etc\ini\python-core.bat to change the Python settings:

PATH %OSGEO4W_ROOT%\apps\Python27\Scripts;%PATH%

You might be tempted to change that, but your pre-existing Python installation might be missing modules that are needed to run QGIS. So temporarily renaming the folder with the pre-existing python might be the easiest solution.

Or compare both Python installs, and copy missing modules from QGIS to PYTHON27. But keep in mind that the next QGIS version will be running with Python 3, making that work redundant.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.