I'm trying to run a Python script in QGIS which imports the colour module. However, when I run it via the Python console in QGIS, I receive the ModuleNotFoundError:
Python Console
Use iface to access QGIS API interface or Type help(iface) for more info
Security warning: typing commands from an untrusted source can lead to data loss and/or leak
import colour
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS 3.10\apps\Python37\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "C:/PROGRA~1/QGIS 3.10/apps/qgis-ltr/./python\qgis\utils.py", line 744, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'colour'
from qgis.core import *
This seems to be a fairly common issue and probably relates to the environment variables. I followed the instructions here for setting my PATH
and PYTHONPATH
variables but still haven't had much success. Oddly enough, I can import colour but not qgis.core
in OSGeo4W. Any advice on how to import the colour module in QGIS successfully?
C:\WINDOWS\system32>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import colour
>>> from qgis.core import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'qgis'
>>>