1

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:

  1. 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.
  2. 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\python was included in PYTHONPATH by default.
  3. Based on a similar post to mine, added ~\anaconda3\envs\qgis_env\Library\bin to PYTHONPATH. This folder contains files like qgis_analysis.dll.
  4. Tried import statements 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:

  1. 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.
  2. 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\python was included in PYTHONPATH by default.
  3. Based on a similar post to mine, added ~\anaconda3\envs\qgis_env\Library\bin to PYTHONPATH. This folder contains files like qgis_analysis.dll.
  4. Tried import statements 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.

teakayist
  • 11
  • 2

0 Answers0