[Qgis-user] Accessing iface from jupyter to create map from QGIS

noshin prachi noshin.prachi at gmail.com
Wed Dec 6 19:13:22 PST 2023


Thank you Adam for your response. I have imported iface from from
qgis.utils import iface. I am working in qgis environment.   It is my first
work with qgis and I am finding it difficult to understand. Can you please
share where I am going wrong? Is there any other way to activate a layer
from multiple layers and create a map?  I have google street map , shape
file and dfsu file in these layers which are required to be added in the
map.

On Wed, 6 Dec 2023 at 18:10, Adam Nielsen via QGIS-User <
qgis-user at lists.osgeo.org> wrote:

> > While trying to activate with iface.setactivelayer I am facing an error.
>
> The error is complaining that iface is None.  Your code doesn't show
> what value you assigned to this variable - where did you set iface and
> what value did you set it to?  I think you forgot to set it and that is
> why you are getting this error.
>
> Cheers,
> Adam.
> _______________________________________________
> QGIS-User mailing list
> QGIS-User at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20231207/24d534e8/attachment.htm>
-------------- next part --------------

(base) C:\Users\FFWS>conda activate qgis

(qgis) C:\Users\FFWS>jupyter notebook
[I 2023-12-06 15:20:33.915 ServerApp] Package notebook took 0.0000s to import
[I 2023-12-06 15:20:33.962 ServerApp] Package jupyter_lsp took 0.0473s to import
[W 2023-12-06 15:20:33.962 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_lsp. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-12-06 15:20:33.993 ServerApp] Package jupyter_server_terminals took 0.0269s to import
[I 2023-12-06 15:20:33.993 ServerApp] Package jupyterlab took 0.0000s to import
[I 2023-12-06 15:20:34.087 ServerApp] Package notebook_shim took 0.0000s to import
[W 2023-12-06 15:20:34.087 ServerApp] A `_jupyter_server_extension_points` function was not found in notebook_shim. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.
[I 2023-12-06 15:20:34.087 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2023-12-06 15:20:34.102 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2023-12-06 15:20:34.118 ServerApp] jupyterlab | extension was successfully linked.
[I 2023-12-06 15:20:34.118 ServerApp] notebook | extension was successfully linked.
[I 2023-12-06 15:20:34.477 ServerApp] notebook_shim | extension was successfully linked.
[I 2023-12-06 15:20:34.509 ServerApp] notebook_shim | extension was successfully loaded.
[I 2023-12-06 15:20:34.509 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2023-12-06 15:20:34.509 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2023-12-06 15:20:34.524 LabApp] JupyterLab extension loaded from C:\Users\FFWS\anaconda3\envs\qgis\lib\site-packages\jupyterlab
[I 2023-12-06 15:20:34.524 LabApp] JupyterLab application directory is C:\Users\FFWS\anaconda3\envs\qgis\share\jupyter\lab
[I 2023-12-06 15:20:34.524 LabApp] Extension Manager is 'pypi'.
[I 2023-12-06 15:20:34.524 ServerApp] jupyterlab | extension was successfully loaded.
[I 2023-12-06 15:20:34.524 ServerApp] notebook | extension was successfully loaded.
[I 2023-12-06 15:20:34.524 ServerApp] Serving notebooks from local directory: C:\Users\FFWS
[I 2023-12-06 15:20:34.524 ServerApp] Jupyter Server 2.10.0 is running at:
[I 2023-12-06 15:20:34.524 ServerApp] http://localhost:8888/tree?token=99f5ac6fd1ec2cac299b0dcc61f5392edd69a7bbed37f1eb
[I 2023-12-06 15:20:34.524 ServerApp]     http://127.0.0.1:8888/tree?token=99f5ac6fd1ec2cac299b0dcc61f5392edd69a7bbed37f1eb
[I 2023-12-06 15:20:34.524 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2023-12-06 15:20:34.571 ServerApp]

    To access the server, open this file in a browser:
        file:///C:/Users/FFWS/AppData/Roaming/jupyter/runtime/jpserver-5788-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/tree?token=99f5ac6fd1ec2cac299b0dcc61f5392edd69a7bbed37f1eb
        http://127.0.0.1:8888/tree?token=99f5ac6fd1ec2cac299b0dcc61f5392edd69a7bbed37f1eb
[I 2023-12-06 15:20:34.665 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
[I 2023-12-06 15:20:41.701 ServerApp] Creating new notebook in
[I 2023-12-06 15:20:48.258 ServerApp] Kernel started: 67fc13ce-4b7f-4808-88c7-72f2aff472c6
[I 2023-12-06 15:20:49.293 ServerApp] Connecting to kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6.
Application path not initialized
Application path not initialized
Application path not initialized
Application path not initialized
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\qt_temp-mrRfgF" most likely due to the presence of read-only files.
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\qt_temp-vPCGST" most likely due to the presence of read-only files.
Empty filename passed to function
Application path not initialized
Application path not initialized
Application path not initialized
QGuiApplication::font(): no QGuiApplication instance and no application font set.
QFontDatabase: Must construct a QGuiApplication before accessing QFontDatabase
[I 2023-12-06 15:22:36.242 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
[W 2023-12-06 15:22:36.242 ServerApp] kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6 restarted
[I 2023-12-06 15:22:36.247 ServerApp] Starting buffering for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:22:36.250 ServerApp] Connecting to kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6.
[I 2023-12-06 15:22:36.250 ServerApp] Restoring connection for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:22:43.903 ServerApp] Saving file at /Untitled14.ipynb
Application path not initialized
Application path not initialized
Application path not initialized
Application path not initialized
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\qt_temp-XueRej" most likely due to the presence of read-only files.
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\qt_temp-gfheBR" most likely due to the presence of read-only files.
Empty filename passed to function
Application path not initialized
Application path not initialized
Application path not initialized
QGuiApplication::font(): no QGuiApplication instance and no application font set.
QFontDatabase: Must construct a QGuiApplication before accessing QFontDatabase
[I 2023-12-06 15:23:57.249 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
[W 2023-12-06 15:23:57.249 ServerApp] kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6 restarted
[I 2023-12-06 15:23:57.251 ServerApp] Starting buffering for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:23:57.265 ServerApp] Connecting to kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6.
[I 2023-12-06 15:23:57.265 ServerApp] Restoring connection for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:24:44.181 ServerApp] Saving file at /Untitled14.ipynb
Application path not initialized
Application path not initialized
Application path not initialized
Application path not initialized
[I 2023-12-06 15:26:15.262 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
[W 2023-12-06 15:26:15.262 ServerApp] kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6 restarted
[I 2023-12-06 15:26:15.271 ServerApp] Starting buffering for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:26:15.274 ServerApp] Connecting to kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6.
[I 2023-12-06 15:26:15.274 ServerApp] Restoring connection for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:26:45.184 ServerApp] Saving file at /Untitled14.ipynb
Application path not initialized
Application path not initialized
Application path not initialized
Application path not initialized
[I 2023-12-06 15:27:12.281 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
[W 2023-12-06 15:27:12.281 ServerApp] kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6 restarted
[I 2023-12-06 15:27:12.283 ServerApp] Starting buffering for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:27:12.290 ServerApp] Connecting to kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6.
[I 2023-12-06 15:27:12.290 ServerApp] Restoring connection for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:28:45.206 ServerApp] Saving file at /Untitled14.ipynb
Application path not initialized
Application path not initialized
Application path not initialized
Application path not initialized
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\qt_temp-SfswQM" most likely due to the presence of read-only files.
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\qt_temp-tdcgCo" most likely due to the presence of read-only files.
Empty filename passed to function
Application path not initialized
Application path not initialized
Application path not initialized
QGuiApplication::font(): no QGuiApplication instance and no application font set.
QFontDatabase: Must construct a QGuiApplication before accessing QFontDatabase
[I 2023-12-06 15:32:00.285 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
[W 2023-12-06 15:32:00.285 ServerApp] kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6 restarted
[I 2023-12-06 15:32:00.285 ServerApp] Starting buffering for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:32:00.304 ServerApp] Connecting to kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6.
[I 2023-12-06 15:32:00.304 ServerApp] Restoring connection for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
Application path not initialized
Application path not initialized
Application path not initialized
Application path not initialized
[I 2023-12-06 15:32:45.245 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 15:36:46.185 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 15:38:46.217 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 15:39:36.326 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
[W 2023-12-06 15:39:36.326 ServerApp] kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6 restarted
[I 2023-12-06 15:39:36.341 ServerApp] Starting buffering for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:39:36.357 ServerApp] Connecting to kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6.
[I 2023-12-06 15:39:36.357 ServerApp] Restoring connection for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 15:40:47.192 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 15:42:47.214 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 15:48:47.985 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 16:01:12.189 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 16:03:12.229 ServerApp] Saving file at /Untitled14.ipynb
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\python-MDMOGG" most likely due to the presence of read-only files.
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\python-YrGOaS" most likely due to the presence of read-only files.
[I 2023-12-06 16:05:12.251 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 16:09:12.282 ServerApp] Saving file at /Untitled14.ipynb
ERROR 6: The PNG driver does not support update access to existing datasets.

[I 2023-12-06 16:19:16.203 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 16:21:16.246 ServerApp] Saving file at /Untitled14.ipynb
ERROR 6: The PNG driver does not support update access to existing datasets.

QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\python-aZugDg" most likely due to the presence of read-only files.
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\python-yAAGgy" most likely due to the presence of read-only files.
ERROR 1: Invalid node descriptor size in .sbn : 360
ERROR 6: The PNG driver does not support update access to existing datasets.

[I 2023-12-06 16:25:18.194 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 16:40:12.215 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 16:40:24.363 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5), keep random ports
[W 2023-12-06 16:40:24.364 ServerApp] kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6 restarted
[I 2023-12-06 16:40:24.366 ServerApp] Starting buffering for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 16:40:24.390 ServerApp] Connecting to kernel 67fc13ce-4b7f-4808-88c7-72f2aff472c6.
[I 2023-12-06 16:40:24.390 ServerApp] Restoring connection for 67fc13ce-4b7f-4808-88c7-72f2aff472c6:30d30d25-d02f-42bf-aa0b-ebe3ba4ec253
[I 2023-12-06 16:42:12.254 ServerApp] Saving file at /Untitled14.ipynb
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\python-imdAqv" most likely due to the presence of read-only files.
QTemporaryDir: Unable to remove "C:\\Users\\FFWS\\AppData\\Local\\Temp\\python-UPDban" most likely due to the presence of read-only files.
[I 2023-12-06 16:44:13.184 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-06 16:46:14.198 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-07 08:36:57.284 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-07 08:56:11.006 ServerApp] Saving file at /Untitled14.ipynb
[I 2023-12-07 08:57:23.349 ServerApp] Creating new notebook in
[I 2023-12-07 08:57:29.208 ServerApp] Kernel started: b8bfc478-e241-4b50-a1b1-7c89f94ac9f5
[I 2023-12-07 08:57:30.256 ServerApp] Connecting to kernel b8bfc478-e241-4b50-a1b1-7c89f94ac9f5.
[I 2023-12-07 08:59:25.234 ServerApp] Saving file at /Untitled15.ipynb
[I 2023-12-07 09:01:26.005 ServerApp] Saving file at /Untitled15.ipynb


More information about the QGIS-User mailing list