My goal is to edit and run qgis scripts in Spyder. I installed Anaconda. Within Anaconda Navigator I created an environment 'qgis_env' with Python 3.9.15, and installed the qgis package in the environment. Then I installed Spyder in the environment and opened Spyder from that environment. import qgis appears to run fine. However any import statement that involves a subpackage like import qgis.analysis or from qgis.core import QgsVectorLayer gives an error ImportError: DLL load failed while importing _analysis: The specified module could not be found.
Things I have tried:
- Uninstalled Anaconda, and also uninstalled any other related but unnecessary standalone installs I already had: QGIS, Python, IDLE, and Spyder. Reinstalled Anaconda and recreated the qgis environment as above.
- Checked
~\anaconda3\envs\qgis_env\Library\python\qgis\. This folder does contain files called_analysis.pyd,_analysis.pyi,_core.pyd, etc.~\anaconda3\envs\qgis_env\Library\pythonwas included inPYTHONPATHby default. - Based on a similar post to mine, added
~\anaconda3\envs\qgis_env\Library\bintoPYTHONPATH. This folder contains files likeqgis_analysis.dll. - Tried
importstatements in JupyterLab.
It is possible that I am missing something basic about Anaconda environments and importing packages/subpackages, but I really thought that I was using these tools the way they are meant to be used. Any help is appreciated.
Things I have tried:
- Uninstalled Anaconda, and also uninstalled any other related but unnecessary standalone installs I already had: QGIS, Python, IDLE, and Spyder. Reinstalled Anaconda and recreated the qgis environment as above.
- Checked
~\anaconda3\envs\qgis_env\Library\python\qgis\. This folder does contain files called_analysis.pyd,_analysis.pyi,_core.pyd, etc.~\anaconda3\envs\qgis_env\Library\pythonwas included inPYTHONPATHby default. - Based on a similar post to mine, added
~\anaconda3\envs\qgis_env\Library\bintoPYTHONPATH. This folder contains files likeqgis_analysis.dll. - Tried
importstatements in JupyterLab.
It is possible that I am missing something basic about Anaconda environments and importing packages/subpackages, but I really thought that I was using these tools the way they are meant to be used. Any help is appreciated.