https://issues.qgis.org/https://issues.qgis.org/favicon.ico2018-08-29T15:32:53ZQGIS Issue TrackingQGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=923072018-08-29T15:32:53ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Category</strong> changed from <i>Customisation Framework</i> to <i>Build/Install</i></li></ul><p>Maybe the category should be "Processing", not sure.</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=923082018-08-29T15:33:15ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>Did it worked as expected on 2.18?</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=925272018-09-04T11:22:59ZAndreas Muellermuellea@uni-trier.de
<ul><li><strong>Assignee</strong> set to <i>Giovanni Manghi</i></li></ul><p>Giovanni Manghi wrote:</p>
<blockquote>
<p>Did it worked as expected on 2.18?</p>
</blockquote>
<p>Yes, the only absolute pathes i can find in QGIS2.ini are lastDirPath and alike. If they do not exists, it doesn't matter.</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=925402018-09-04T14:36:17ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Priority</strong> changed from <i>Normal</i> to <i>High</i></li><li><strong>Regression?</strong> changed from <i>No</i> to <i>Yes</i></li><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Open</i></li><li><strong>Assignee</strong> deleted (<del><i>Giovanni Manghi</i></del>)</li></ul> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1000002019-02-12T16:28:20ZLuigi Pirelliluipir@gmail.com
<ul><li><strong>Assignee</strong> set to <i>Luigi Pirelli</i></li></ul><p>investigating</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1001212019-02-13T17:59:28ZLuigi Pirelliluipir@gmail.com
<ul><li><strong>Pull Request or Patch supplied</strong> changed from <i>No</i> to <i>Yes</i></li></ul><p>proposed PR<br /><a class="external" href="https://github.com/qgis/QGIS/pull/9172">https://github.com/qgis/QGIS/pull/9172</a></p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1001222019-02-13T18:01:58ZLuigi Pirelliluipir@gmail.com
<ul></ul><p>please Andreas Mueller give a look of the related unit test if it cover your requirements</p>
<p><a class="external" href="https://github.com/qgis/QGIS/blob/a2bf5ccefd5363bb06d607d2dd5925fd82816cad/python/plugins/processing/tests/ScriptUtilsTest.py#L53">https://github.com/qgis/QGIS/blob/a2bf5ccefd5363bb06d607d2dd5925fd82816cad/python/plugins/processing/tests/ScriptUtilsTest.py#L53</a></p>
<p>or better build with the path and check if it owrks in your use cases.</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1001512019-02-14T10:38:41ZAndreas Muellermuellea@uni-trier.de
<ul></ul><p>Thank you for your efforts Luigi,</p>
<p>i looked into the test, but i don't totally understand the code, I'm sorry. Also I never build qgis from source and it is not an option at the moment.</p>
<p>But i tried to use the new scripts ScriptAlgorithmProvider.py and ScriptUtils.py with my installed qqis (3.4.3) which gives an error, so i think there are other changes in the code since 3.4.3. Error is:</p>
<pre><code>2019-02-14T10:57:07 WARNING Traceback (most recent call last):<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python\qgis\utils.py", line 309, in loadPlugin<br /> <i>import</i>(packageName)<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python\qgis\utils.py", line 672, in <em>import<br /> mod = _builtin_import(name, globals, locals, fromlist, level)<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python/plugins\processing\</em>_init__.py", line 29, in <br /> from processing.tools.general import * # NOQA<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python\qgis\utils.py", line 672, in _import<br /> mod = _builtin_import(name, globals, locals, fromlist, level)<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python/plugins\processing\tools\general.py", line 39, in <br /> from processing.core.Processing import Processing<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python\qgis\utils.py", line 672, in _import<br /> mod = _builtin_import(name, globals, locals, fromlist, level)<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python/plugins\processing\core\Processing.py", line 55, in <br /> from processing.script import ScriptUtils<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python\qgis\utils.py", line 672, in _import<br /> mod = _builtin_import(name, globals, locals, fromlist, level)<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python/plugins\processing\script\ScriptUtils.py", line 28, in <br /> from qgis.processing import alg as algfactory<br /> File "H:/gp181030/osgeo4w/apps/qgis/./python\qgis\utils.py", line 672, in _import<br /> mod = _builtin_import(name, globals, locals, fromlist, level)<br /> ModuleNotFoundError: No module named 'qgis.processing'</code></pre>
<p>What i have done to overcome the originally issue is running a script to change entries in the ini-Files QGIS3.ini in Profiles/default/QGIS and qgis_global_settings.ini in apps/qgis/resources:</p>
<pre><code>import os<br /> from PyQt5.QtCore import QSettings<br /> inipath_profile = os.path.join(os.environ['Home'],'.qis3/profiles/default/QGIS/QGIS3.ini')<br /> if os.path.exists(inipath_profile):<br /> settings_profile = QSettings(inipath_profile, QSettings.IniFormat);<br /> else:<br /> settings_profile = None<br /> inipath_global = os.path.join(os.environ['OSGEO4W_ROOT'],'apps/qgis/resources/qgis_global_settings.ini')<br /> settings_global = QSettings(inipath_global, QSettings.IniFormat);<br /> envdict = {}<br /> try:<br /> home =os.environ['HOME'] # G:\\gp180823\\Home<br /> envdict["Processing/Configuration/MODELS_FOLDER"] = os.path.realpath(home + "\.qis3\profiles\default\processing\models")<br /> envdict["Processing/Configuration/OUTPUTS_FOLDER"] = os.path.realpath(home + "\.qis3\profiles\default\processing\outputs")<br /> envdict["Processing/Configuration/SCRIPTS_FOLDERS"] = os.path.realpath(home + "\.qis3\profiles\default\processing\scripts")<br /> envdict["qgis/projectTemplateDir"] = os.path.realpath(home + "\.qis3\profiles\default/project_templates")<br /> except Exception as e:<br /> exit("Environment variable 'Home' not set!")<br /> try:<br /> prefix = os.environ['GISBASE'] # G:\gp180823\osgeo4w\apps\grass\grass-7.4.1<br /> envdict["Processing/Configuration/GRASS7_FOLDER"] = os.path.realpath(prefix)<br /> envdict["Processing/Configuration/GRASS_HELP_PATH"] = os.path.realpath(prefix + "\docs\html")<br /> except Exception as e:<br /> print ("Environment variable 'GISBASE' not set!")<br /> for k in envdict.keys():<br /> settings_global.setValue(k, envdict[k])<br /> print('globals', k, envdict[k])<br /> if settings_profile is not None and settings_profile.contains(k):<br /> print('key %s exists in profile'%k)<br /> if not os.path.exists(settings_profile.value(k)):<br /> print('path %s does not exists, writing default to profile'%settings_profile.value(k))<br /> print('profiles', k, envdict[k])<br /> settings_profile.setValue(k, envdict[k])<br /> else:<br /> print('path %s exists, left it in profiles!'%settings_profile.value(k))<br /> else:<br /> print('key %s does not exists in profile, left empty', k)<br /> settings_global.sync()<br /> if settings_profile is not None: <br /> settings_profile.sync()</code></pre>
<p>I know that's not a proper solution, but may be it shows better, what/where the issue is...</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1001532019-02-14T12:18:24ZLuigi Pirelliluipir@gmail.com
<ul></ul><p>Andreas Mueller wrote:</p>
<blockquote>
<p>Thank you for your efforts Luigi,</p>
<p>i looked into the test, but i don't totally understand the code, I'm sorry. Also I never build qgis from source and it is not an option at the moment.</p>
</blockquote>
<p>no problem</p>
<blockquote>
<p>But i tried to use the new scripts ScriptAlgorithmProvider.py and ScriptUtils.py with my installed qqis (3.4.3) which gives an error, so i think there are other changes in the code since 3.4.3. Error is:</p>
</blockquote>
<p>confirmed... but the Patch is for master not for 3.4.x where ScriptUtils has a different code base... you should use qgis-dev in osgeo4w</p>
<blockquote>
<p>What i have done to overcome the originally issue is running a script to change entries in the ini-Files QGIS3.ini in Profiles/default/QGIS and qgis_global_settings.ini in apps/qgis/resources:</p>
<p>I know that's not a proper solution, but may be it shows better, what/where the issue is...</p>
</blockquote>
<p>my patch works only for Script path but the function I added can be used to reset any config path to the acrual profile path</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1001542019-02-14T12:25:50ZLuigi Pirelliluipir@gmail.com
<ul></ul><p>BTW no idea why you using .qgis3... scripts re usually saved in:<br />C:\Users\<yout user>\AppData\Roaming\QGIS\QGIS3\profiles\<yout profile>\processing\scripts</p>
<p>what kind of installer are you using? I'm using the advanced OSGeo4W installer (not the standalone application) that shoudl istall stuffs in the same paths</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1001572019-02-14T12:57:27ZAndreas Muellermuellea@uni-trier.de
<ul></ul><p>I use apt by Matt Wilkie (<a class="external" href="https://github.com/maphew/apt">https://github.com/maphew/apt</a>), which i changed to use modified postinstall batch-files for a installation on removable drives. But the reason why i use .qgis3 for profiles is that i wanted to store the profiles along with qgis on an usb-stick and I start qgis with --profiles-path. I used the according option under qgis2 too, then it pointed to .qgis2.<br />Since i have more "portable" software on usb sticks, i encountered, that it is possible to redirect even AppData through an environment variable, so this could also be an option. Some Qt-Applications I tested unfortunately don't use the environment variables <span>APPDATA</span> and <span>LOCALAPPDATA</span> and i didn't test it for qgis.</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1001592019-02-14T13:30:22ZLuigi Pirelliluipir@gmail.com
<ul></ul><p>I'll check if my patch works in your custom configuration</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1042542019-04-29T08:50:43ZLuigi Pirelliluipir@gmail.com
<ul></ul><p>partially fixed by <a class="external" href="https://github.com/qgis/QGIS/pull/9172">https://github.com/qgis/QGIS/pull/9172</a> but IMHO I do not think it cover all. Please check @andreas</p> QGIS Application - Bug report #19731: Python error at qgis startup after changing profile folderhttps://issues.qgis.org/issues/19731?journal_id=1043122019-05-01T15:59:46ZGiovanni Manghigiovanni.manghi@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul>