I continue to have very time-consuming problems with import statements in the Python scripts that I attempt to write.
In this particular script, I want to use QGIS functionality, and so it begins:
from qgis.core import *
which causes:
Traceback (most recent call last):
File "C:\Python script for PUI\v20170621.py", line 8, in <module>
from qgis.core import *
ImportError: No module named qgis.core
So I try:
import sys
sys.path.append('C:/Program Files (x86)/QGIS 2.18/apps/qgis/python')
from qgis.core import *
which causes:
Traceback (most recent call last):
File "C:\Python script for PUI\v20170621.py", line 8, in <module>
from qgis.core import *
File "C:/Program Files (x86)/QGIS 2.18/apps/qgis/python\qgis\__init__.py", line 26, in <module>
from qgis.PyQt import QtCore
File "C:/Program Files (x86)/QGIS 2.18/apps/qgis/python\qgis\PyQt\QtCore.py", line 26, in <module>
import sip
ImportError: No module named sip
There is a folder named 'sip' in 'C:\Program Files (x86)\QGIS 2.18\apps\python27' and so I try:
import sys
sys.path.append('C:/Program Files (x86)/QGIS 2.18/apps/qgis/python')
sys.path.append('C:/Program Files (x86)/QGIS 2.18/apps/python27')
from qgis.core import *
which again causes the 2nd error above:
Traceback (most recent call last):
...
ImportError: No module named sip
I suspect that I have a very fundamental misunderstanding about how modules/libraries are installed/imported/loaded/etc. Why can I not simply copy the necessary folder(s) (for instance, the folder 'sip' in this case) to some folder in 'C:\Python27\ArcGIS10.1' (which is where the 'python.exe' file is located that IDLE calls when I open and execute the script) so that no update to PATH nor PYTHONPATH is required?