pgRouting / pgRoutingLayer

pgRouting Layer plugin for QGIS
https://qgis.pgrouting.org/
GNU General Public License v2.0
23 stars 18 forks source link

Error when opening the plugin in QGIS #90

Closed MarPetra closed 5 years ago

MarPetra commented 5 years ago
Couldn't load plugin 'pgroutinglayer' due to an error when calling its classFactory() method 

ModuleNotFoundError: No module named 'pgRoutingLayer' 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 335, in startPlugin
    plugins[packageName] = package.classFactory(iface)
  File "/home/marpetra/.local/share/QGIS/QGIS3/profiles/pgrouting/python/plugins/pgroutinglayer/__init__.py", line 36, in classFactory
    from pgRoutingLayer.pgRoutingLayer import PgRoutingLayer
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 672, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'pgRoutingLayer'

Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0] 
QGIS version: 3.4.2-Madeira Madeira, 5645791 

Python Path:
/usr/share/qgis/python
/home/marpetra/.local/share/QGIS/QGIS3/profiles/pgrouting/python
/home/marpetra/.local/share/QGIS/QGIS3/profiles/pgrouting/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python36.zip
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/usr/local/lib/python3.6/dist-packages
/usr/lib/python3/dist-packages
/home/marpetra/.local/share/QGIS/QGIS3/profiles/pgrouting/python
cvvergara commented 5 years ago

if I use name: pgRoutingLayer on pb_tools.cfg I get this error

Couldn't load plugin 'pgRoutingLayer' due to an error when calling its initGui() method 

ModuleNotFoundError: No module named 'pgRoutingLayer.connectors' 
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 344, in startPlugin
    plugins[packageName].initGui()
  File "/home/vicky/.local/share/QGIS/QGIS3/profiles/pgrouting/python/plugins/pgRoutingLayer/pgRoutingLayer.py", line 219, in initGui
    self.reloadConnections()
  File "/home/vicky/.local/share/QGIS/QGIS3/profiles/pgrouting/python/plugins/pgRoutingLayer/pgRoutingLayer.py", line 243, in reloadConnections
    actions = conn.getAvailableConnections()
  File "/home/vicky/.local/share/QGIS/QGIS3/profiles/pgrouting/python/plugins/pgRoutingLayer/dbConnection.py", line 54, in getAvailableConnections
    connection = self.getConnection( c )
  File "/home/vicky/.local/share/QGIS/QGIS3/profiles/pgrouting/python/plugins/pgRoutingLayer/dbConnection.py", line 38, in getConnection
    exec( "from pgRoutingLayer.connectors import %s as connector" % conntype, globals(),globals())
  File "", line 1, in 
  File "/usr/lib/python3/dist-packages/qgis/utils.py", line 672, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'pgRoutingLayer.connectors'

Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) [GCC 8.2.0] 
QGIS version: 3.4.2-Madeira Madeira, 5645791 

Python Path:
/usr/share/qgis/python
/home/vicky/.local/share/QGIS/QGIS3/profiles/pgrouting/python
/home/vicky/.local/share/QGIS/QGIS3/profiles/pgrouting/python/plugins
/usr/share/qgis/python/plugins
/usr/lib/python36.zip
/usr/lib/python3.6
/usr/lib/python3.6/lib-dynload
/usr/local/lib/python3.6/dist-packages
/usr/lib/python3/dist-packages
/home/vicky/.local/share/QGIS/QGIS3/profiles/pgrouting/python
cayetanobv commented 5 years ago

@MarPetra @cvvergara you need to change several properties by hand (plugin name - it is case sensitive-, extra_dirs, and extras) in your pb_too_cfg file. Example:

# Configuration file for plugin builder tool
# Sane defaults for your plugin generated by the Plugin Builder are
# already set below.
#
# As you add Python source files and UI files to your plugin, add
# them to the appropriate [files] section below.

[plugin]
# Name of the plugin. This is the name of the directory that will
# be created when deployed
name: pgRoutingLayer

# Full path to where you want your plugin directory copied. If empty,
# the QGIS default path will be used. Don't include the plugin name in
# the path.
plugin_path:

[files]
# Python  files that should be deployed with the plugin
python_files: pgRoutingLayer.py dbConnection.py __init__.py pgRoutingLayer_utils.py

# The main dialog file that is loaded (not compiled)
main_dialog:

# Other ui files for your dialogs (these will be compiled)
compiled_ui_files: ui_pgRoutingLayer.ui

# Resource file(s) that will be compiled
resource_files:

# Other files required for the plugin
extras: icon.png metadata.txt ui_pgRoutingLayer.ui

# Other directories to be deployed with the plugin.
# These must be subdirectories under the plugin directory
extra_dirs: connectors functions

# ISO code(s) for any locales (translations), separated by spaces.
# Corresponding .ts files must exist in the i18n directory
locales:

[help]
# the built help directory that should be deployed with the plugin
dir: help/build/html
# the name of the directory to target in the deployed plugin
target: help
cvvergara commented 5 years ago

Thanks it worked

Yehoh commented 5 years ago

Hi, I have the same issue as first mentioned, however I don't get how to fix it : My understanding is that you currently use the plugin Plugin Builder to locally build the pgRoutingLayer plugin for QGIS v3. Is this actually how you do the trick ?

In that case how can I set up pgRoutingLayer using Plugin Builder ? I tried, unfortunately it doesn't work for me as it doesn't come clear to me as to how correctly set the plugin and settings.

cvvergara commented 5 years ago

@Yehoh This worked on develop branch, develop is where we are making the changes for the beta release you need to pip install pb_tool

cvvergara commented 5 years ago

https://github.com/pgRouting/pgRoutingLayer/wiki/How-to:-test-pgRoutingLayer-3