Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhable to import QGIS in windows powershell #210

Open
1 task done
SrNetoChan opened this issue Oct 6, 2021 · 5 comments
Open
1 task done

Unhable to import QGIS in windows powershell #210

SrNetoChan opened this issue Oct 6, 2021 · 5 comments

Comments

@SrNetoChan
Copy link
Contributor

Issue:

It seems that the activate.bt script is not suited for windows powershell and QGIS Python path is not added to the PYTHONPATH variable. Everything works fine if one uses the old command line prompt instead.


Environment (conda list):
(qgis_ltr) C:\Users\tests>conda list
# packages in environment at C:\Users\tests\miniconda3\envs\qgis_ltr:
#
# Name                    Version                   Build  Channel
boost-cpp                 1.74.0               h54f0996_3    conda-forge
brotlipy                  0.7.0           py39hb82d6ee_1001    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2021.5.30            h5b45459_0    conda-forge
cairo                     1.16.0            hb19e0ff_1008    conda-forge
certifi                   2021.5.30        py39hcbf5309_0    conda-forge
cffi                      1.14.6           py39h0878f49_1    conda-forge
cfitsio                   3.470                h0af3d06_7    conda-forge
chardet                   4.0.0            py39hcbf5309_1    conda-forge
coverage                  6.0              py39hb82d6ee_0    conda-forge
cryptography              3.4.7            py39hd8d06c1_0    conda-forge
curl                      7.79.1               h789b8ee_1    conda-forge
exiv2                     0.27.1               hfa2c1cf_0    conda-forge
expat                     2.4.1                h39d44d4_0    conda-forge
fontconfig                2.13.1            h1989441_1005    conda-forge
freetype                  2.10.4               h546665d_1    conda-forge
freexl                    1.0.6                ha8e266a_0    conda-forge
future                    0.18.2           py39hcbf5309_3    conda-forge
gdal                      3.2.1            py39h6795fcd_7    conda-forge
geos                      3.9.1                h39d44d4_2    conda-forge
geotiff                   1.6.0                hee96dd5_4    conda-forge
gettext                   0.19.8.1          ha2e2712_1008    conda-forge
gsl                       2.6                  hdfb1a43_2    conda-forge
hdf4                      4.2.15               h0e5069d_3    conda-forge
hdf5                      1.10.6          nompi_h5268f04_1114    conda-forge
httplib2                  0.19.1             pyhd8ed1ab_0    conda-forge
icu                       68.1                 h0e60522_0    conda-forge
idna                      2.10               pyh9f0ad1d_0    conda-forge
intel-openmp              2021.3.0          h57928b3_3372    conda-forge
jinja2                    3.0.1              pyhd8ed1ab_0    conda-forge
jpeg                      9d                   h8ffe710_0    conda-forge
kealib                    1.4.14               h96bfa42_2    conda-forge
krb5                      1.19.2               hbae68bd_2    conda-forge
libblas                   3.9.0              11_win64_mkl    conda-forge
libcblas                  3.9.0              11_win64_mkl    conda-forge
libclang                  11.1.0          default_h5c34c98_1    conda-forge
libcurl                   7.79.1               h789b8ee_1    conda-forge
libffi                    3.4.2                h0e60522_4    conda-forge
libgdal                   3.2.1                hca2c63a_7    conda-forge
libglib                   2.68.4               h3be07f2_1    conda-forge
libiconv                  1.16                 he774522_0    conda-forge
libkml                    1.3.0             h9859afa_1014    conda-forge
liblapack                 3.9.0              11_win64_mkl    conda-forge
libnetcdf                 4.7.4           nompi_h3a9aa94_107    conda-forge
libpng                    1.6.37               h1d00b33_2    conda-forge
libpq                     13.3                 hfcc5ef8_0    conda-forge
libprotobuf               3.16.0               h7755175_0    conda-forge
librttopo                 1.1.0                hb340de5_6    conda-forge
libspatialindex           1.9.3                h39d44d4_4    conda-forge
libspatialite             5.0.1                h987baeb_3    conda-forge
libssh2                   1.10.0               h680486a_2    conda-forge
libtiff                   4.2.0                h763f289_2    conda-forge
libwebp                   1.2.1                h57928b3_0    conda-forge
libwebp-base              1.2.1                h8ffe710_0    conda-forge
libxml2                   2.9.12               hf5bbc77_0    conda-forge
libxslt                   1.1.33               h65864e5_2    conda-forge
libzip                    1.8.0                hfed4ece_1    conda-forge
libzlib                   1.2.11            h8ffe710_1013    conda-forge
lz4-c                     1.9.3                h8ffe710_1    conda-forge
markupsafe                2.0.1            py39hb82d6ee_0    conda-forge
mkl                       2021.3.0           hb70f87d_564    conda-forge
mock                      4.0.3            py39hcbf5309_1    conda-forge
nose2                     0.9.2                      py_0    conda-forge
numpy                     1.21.2           py39h6635163_0    conda-forge
openjpeg                  2.4.0                hb211442_1    conda-forge
openssl                   1.1.1l               h8ffe710_0    conda-forge
owslib                    0.25.0             pyhd8ed1ab_0    conda-forge
pcre                      8.45                 h0e60522_0    conda-forge
pip                       21.2.4             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h8ffe710_0    conda-forge
plotly                    5.3.1              pyhd8ed1ab_0    conda-forge
poppler                   0.89.0               h3772339_5    conda-forge
poppler-data              0.4.11               hd8ed1ab_0    conda-forge
postgresql                13.3                 h1c22c4f_0    conda-forge
proj                      7.2.0                h1cfcee9_2    conda-forge
psycopg2                  2.9.1            py39h0878f49_0    conda-forge
pycparser                 2.20               pyh9f0ad1d_2    conda-forge
pygments                  2.10.0             pyhd8ed1ab_0    conda-forge
pyopenssl                 21.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 2.4.7              pyh9f0ad1d_0    conda-forge
pyproj                    3.1.0            py39h41cdc1e_3    conda-forge
pyqt                      5.12.3           py39hcbf5309_7    conda-forge
pyqt-impl                 5.12.3           py39h415ef7b_7    conda-forge
pyqt5-sip                 4.19.18          py39h415ef7b_7    conda-forge
pyqtchart                 5.12             py39h415ef7b_7    conda-forge
pyqtwebengine             5.12.1           py39h415ef7b_7    conda-forge
pyqtwebkit                5.212            py39h8235778_1    conda-forge
pysocks                   1.7.1            py39hcbf5309_3    conda-forge
python                    3.9.7           h7840368_3_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytz                      2021.1             pyhd8ed1ab_0    conda-forge
pyyaml                    5.4.1            py39hb82d6ee_1    conda-forge
qca                       2.2.1                hd7ce7fb_3    conda-forge
qgis                      3.16.11          py39hda476ad_1    conda-forge
qjson                     0.9.0             hd7ce7fb_1006    conda-forge
qscintilla2               2.11.2           py39h8235778_4    conda-forge
qt                        5.12.9               h5909a2a_4    conda-forge
qtkeychain                0.12.0               h552f0f6_0    conda-forge
qtlocation                5.12.9               ha925a31_0    conda-forge
qtwebkit                  5.212                hb258684_1    conda-forge
qwt                       6.1.6                h552f0f6_0    conda-forge
qwtpolar                  1.1.1                hd7ce7fb_7    conda-forge
requests                  2.25.1             pyhd3deb0d_0    conda-forge
setuptools                58.0.4           py39hcbf5309_2    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sqlite                    3.36.0               h8ffe710_2    conda-forge
tbb                       2021.3.0             h2d74725_0    conda-forge
tenacity                  8.0.1              pyhd8ed1ab_0    conda-forge
tiledb                    2.2.9                hf84e3da_0    conda-forge
tk                        8.6.11               h8ffe710_1    conda-forge
tzdata                    2021b                he74cb21_0    conda-forge
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
urllib3                   1.26.7             pyhd8ed1ab_0    conda-forge
vc                        14.2                 hb210afc_5    conda-forge
vs2015_runtime            14.29.30037          h902a5da_5    conda-forge
wheel                     0.37.0             pyhd8ed1ab_1    conda-forge
win_inet_pton             1.1.0            py39hcbf5309_2    conda-forge
xerces-c                  3.2.3                h0e60522_2    conda-forge
xz                        5.2.5                h62dcd97_1    conda-forge
yaml                      0.2.5                he774522_0    conda-forge
zlib                      1.2.11            h8ffe710_1013    conda-forge
zstd                      1.4.9                h6255e5f_0    conda-forge


Details about conda and system ( conda info ):
(qgis_ltr) PS C:\Users\tests> conda info

     active environment : qgis_ltr
    active env location : C:\Users\tests\miniconda3\envs\qgis_ltr
            shell level : 2
       user config file : C:\Users\tests\.condarc
 populated config files :
          conda version : 4.10.3
    conda-build version : not installed
         python version : 3.9.5.final.0
       virtual packages : __win=0=0
                          __archspec=1=x86_64
       base environment : C:\Users\tests\miniconda3  (writable)
      conda av data dir : C:\Users\tests\miniconda3\etc\conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:\Users\tests\miniconda3\pkgs
                          C:\Users\tests\.conda\pkgs
                          C:\Users\tests\AppData\Local\conda\conda\pkgs
       envs directories : C:\Users\tests\miniconda3\envs
                          C:\Users\tests\.conda\envs
                          C:\Users\tests\AppData\Local\conda\conda\envs
               platform : win-64
             user-agent : conda/4.10.3 requests/2.25.1 CPython/3.9.5 Windows/10 Windows/10.0.19042
          administrator : False
             netrc file : None
           offline mode : False

(qgis_ltr) PS C:\Users\tests>

@gillins
Copy link
Contributor

gillins commented Oct 7, 2021

@SrNetoChan I don't know anything about PowerShell, but GDAL has PowerShell support (https://github.com/conda-forge/gdal-feedstock/blob/master/recipe/scripts/activate.ps1) - maybe these scripts could be used as the basis for support in QGIS?

@gillins
Copy link
Contributor

gillins commented Nov 30, 2022

Did you manage to work this one out @SrNetoChan ?

@SrNetoChan
Copy link
Contributor Author

Didn't try much. Seems that PowerShell is not that popular for windows users.

@QBBAA
Copy link

QBBAA commented Apr 26, 2023

I have similar problem. Though i haved installed QGIS module, when i try to run my python code with powershell it can not run successfully, and error output is "ModuleNotFoundError: No module named 'qgis'".But if i run the same python code with cmd, it will be ok.

@SrNetoChan
Copy link
Contributor Author

Yes, we would need to create activate scripts for ps1, like GDAL did. Unfortunately, I don't have the time (or need) for it. Let's keep this open anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants