Skip to content

Commit 3633694

Browse files
authored
update(pyqgis-venv): add section about qgis-venv-creator usage (#44)
@nicogodet can you review please?
2 parents 24902cc + 36eb98c commit 3633694

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

content/posts/2024-11-25_pyqgis_environnement_dev_windows.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,42 @@ I will assume that you have installed QGIS in the `C:\OSGeo4W` directory (the pr
8989
command = C:\OSGeo4W\apps\Python312\python.exe -m venv --system-site-packages <The full path to your venv>
9090
```
9191
92+
### With the _qgis-venv-creator_ utility
93+
94+
> Paragraph added in March 2025
95+
96+
![Gispo logo](https://cdn.geotribu.fr/img/logos-icones/entreprises_association/Gispo.webp){: .img-thumbnail-left }
97+
98+
Just after this article was published, we discovered [the create-qgis-venv project](https://github.com/GispoCoding/qgis-venv-creator) by GispoCoding.
99+
100+
It is a multi-platform command-line tool (CLI). It is recommended to install it using [pipx](https://pipx.pypa.io/stable/#on-windows), which handles most of the tricky setup and is compatible with Windows. It's now the recommended tool in the Python community for managing command-line tools (CLI), so this is a great opportunity to start using it. Once pipx is installed, configured (`ensurepath`...), and a new PowerShell session is started, the installation runs smoothly:
101+
102+
```powershell title="Installing qgis-venv-creator with pipx"
103+
pipx install qgis-venv-creator
104+
```
105+
106+
![Installing qgis-venv-creator with pipx](https://cdn.geotribu.fr/img/articles-blog-rdp/articles/2024/pyqgis_environnement_dev_windows/powershell_pipx_qgis-venv-creator.webp){: .img-center loading=lazy }
107+
108+
The qgis-venv-creator tool is now accessible from any PowerShell session with the following command:
109+
110+
```powershell title="Basic command for qgis-venv-creator"
111+
create-qgis-venv --venv-name ".venv"
112+
```
113+
114+
The tool needs to identify the QGIS installation to use for generating the development environment. By default, it searches in `C:\OSGeo4W` and `C:\PROGRAMFILES\QGIS X.y.z`. However, if you are meticulous and use QGIS in a professional environment, you probably install it in a location recommended by the operating system, such as `%PROGRAMFILES%/QGIS/X_y`. You can specify a _pattern_ to indicate where it should look:
115+
116+
```powershell title="qgis-venv-creator with a custom QGIS installation path"
117+
create-qgis-venv --qgis-installation-search-path-pattern "C:\Program Files\QGIS\*\apps\qgis*" --venv-name ".venv"
118+
```
119+
120+
<iframe title="qgis-venv-creator demonstration" width="100%" height="400" src="https://video.osgeo.org/videos/embed/9b5806ca-d489-443f-8edc-d6be9b9a83c6" frameborder="0" allowfullscreen="" sandbox="allow-same-origin allow-scripts allow-popups allow-forms"></iframe>
121+
122+
Simply activate your virtual environment `.venv/Scripts/activate` and continue this tutorial!
123+
Thanks, Gispo!
124+
125+
!!! tip
126+
Good news, it does also work on Linux 🥳 🐧!
127+
92128
----
93129

94130
## In VS Code

0 commit comments

Comments
 (0)