Sunday, 18 September 2016

python 2.7 - QGIS corrupted plugins upon reinstallation


I had various bugs in my GIS softwares (QGIS, ArcGIS) after uninstalling PyCharm from my computer (time limited school license). For a school assignment we had to change the PythonPATH and PythonHOME and after uninstalling the said IDE, some plugins stoped working in QGIS.


I uninstalled the programs, ran CCleaner to remove old registries and just re-installed these:



  • ArcGIS 10.2

  • OSGeo4W (including QGIS Lyon 2.12.3)

  • OpenGeoSuite 4.8 (without QGIS)

  • Python 2.7


  • PyScripter


Now the Processing toolbox and other plugins are corrupted and there is this error message:


AttributeError: 'module' object has no attribute 'openssl_md_meth_names'


Also, when the program starts I have other Python errors.


Impossible to load fTools plugin provokes error when calling classFactory()


(translated from french)


Here's the logfile:


Traceback (most recent call last):
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 306, in startPlugin

plugins[packageName] = package.classFactory(iface)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\fTools\__init__.py", line 33, in classFactory
from .fTools import fToolsPlugin
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 572, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\fTools\fTools.py", line 52, in
import doRandom
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 572, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4~1\apps\qgis\python\plugins\fTools\tools\doRandom.py", line 37, in

import random
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 572, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\Python27\Lib\random.py", line 49, in
import hashlib as _hashlib
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 572, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\Python27\Lib\hashlib.py", line 138, in
_hashlib.openssl_md_meth_names)
AttributeError: 'module' object has no attribute 'openssl_md_meth_names'


Answer



Cleaning registries and re-installations did not solve the problem.


I opened C:\Python27\Lib\hashlib.py (the problematic file) in Notepad++ and checked on line 138 (where the problem was specified) and compared it to the same file on an other computer, where QGIS works correctly.


Note: I only edited the python file, not the compiled python file.


I found 2 extra command lines that I commented out (using #) for the code to be like the one on the working computer.


I saved the file, re-opened QGIS and found no error and geoprocessing tool back.


Here are the 2 extra lines that I commented out in case someone else gets a similar problem:


(first line = 133)


try:
import _hashlib

new = __hash_new
__get_hash = __get_openssl_constructor
# algorithms_available = algorithms_available.union(
# _hashlib.openssl_md_meth_names)
except ImportError:
new = __py_new
__get_hash = __get_builtin_constructor

(last line = 141)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...