Re: [Qgis-user] Running QGis on a machine with Python 3.11 and PyCharm ?
Hi, Le lun. 12 juin 2023 à 10:58, Johannes Kröger (WhereGroup) via QGIS-User < qgis-user@lists.osgeo.org> a écrit : > Hi, > [snip] > The internet is full of ancient, random and poorly compiled batch scripts > which really shouldn't be used anymore. > Great point! This is where IMHO QGIS official documentation should have a say and play an authoritative role, with up to date, clear and meaningful instructions. This topic of configuring QGIS with python environment is to some extent "discussed" at [0] and [1]. Do these pages meet the conditions to play that authoritative role? I'm not that sure, given how recurring the topic arises, but TBH I'm not versed enough in Python to be fully credible. [0] https://docs.qgis.org/3.28/en/docs/pyqgis_developer_cookbook/plugins/ide_debugging.html#debugging-with-pycharm-on-ubuntu-with-a-compiled-qgis [1] https://docs.qgis.org/3.28/en/docs/pyqgis_developer_cookbook/intro.html#python-applications Regards, Harrissou > Cheers, Hannes > Am 09.06.23 um 18:11 schrieb Toussaint OTTAVI via QGIS-User: > > Hi, > > I'm new to QGis. I'm trying to install latest version (3.28.7 LTR) on my > machine. It does not run. The startup window shows during a few seconds, > then, nothing. > > I tried several older versions. None of them wants to start. The exception > is 3.14, which starts, and works perfectly. > > On my machine, I already have a Python 3 installed (currently, 3.11.1), on > absolute path C:\Python, PYTHONPATH system variable pointing to it, and > system path, too. I also have PyCharm installed. I think this may be the > cause of my problem. I noticed the included interpreter (C:\Program > Files\QGIS 3.28.7\bin\python.exe) does not start at all, with Python error : >File "C:\Python\Lib\io.py", line 54, in >ImportError: cannot import name 'text_encoding' from 'io' (unknown > location) > > If I understand well, I'll have to write a customized startup script, with > correct path (not pointing to my c:\python\lib) so that QGis can start > using the included Python interpreter (and not my system-wide one). But I > didn't find how to achieve that. > > Later, I think I'll have to write some QGis Python code. Then, I'll need > to run it in "developer" mode : being able to put the source code in a git > repository, edit the code in PyCharm, and run it. Any clues are welcome. > > Thank you in advance. Kind regards > > ___ > QGIS-User mailing listqgis-u...@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-user > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user > > -- > Johannes Kröger / GIS-Entwickler/-Berater > > - > Aufwind durch Wissen! > Web-Seminare und Online-Schulungen > bei der www.foss-academy.com > - > > WhereGroup GmbH > c/o KK03 GmbH > Lange Reihe 29 > 20099 Hamburg > Germany > > Tel: +49 (0)228 / 90 90 38 - 36 > Fax: +49 (0)228 / 90 90 38 - 11 > johannes.kroe...@wheregroup.comwww.wheregroup.com > Geschäftsführer: > Olaf Knopp, Peter Stamm > Amtsgericht Bonn, HRB 9885 > --- > > ___ > QGIS-User mailing list > QGIS-User@lists.osgeo.org > List info: https://lists.osgeo.org/mailman/listinfo/qgis-user > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user > ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] Running QGis on a machine with Python 3.11 and PyCharm ?
Hi, if you did anything to your PYTHONPATH or other system variables, revert and restore how it was before. On Windows QGIS comes with its own Python interpreter, environment etc etc. If you want to develop QGIS things, you should use that. If you use a separate Python installation you will have lots of pain and confusion. In Pycharm simply set the project interpreter to the python-qgis.bat or python-qgis-ltr.bat file in your QGIS installation's "bin" directory (e.g. "C:\Program Files\QGIS\bin\python-qgis-ltr.bat"). This will magically make sure everything works. The internet is full of ancient, random and poorly compiled batch scripts which really shouldn't be used anymore. Cheers, Hannes Am 09.06.23 um 18:11 schrieb Toussaint OTTAVI via QGIS-User: Hi, I'm new to QGis. I'm trying to install latest version (3.28.7 LTR) on my machine. It does not run. The startup window shows during a few seconds, then, nothing. I tried several older versions. None of them wants to start. The exception is 3.14, which starts, and works perfectly. On my machine, I already have a Python 3 installed (currently, 3.11.1), on absolute path C:\Python, PYTHONPATH system variable pointing to it, and system path, too. I also have PyCharm installed. I think this may be the cause of my problem. I noticed the included interpreter (C:\Program Files\QGIS 3.28.7\bin\python.exe) does not start at all, with Python error : File "C:\Python\Lib\io.py", line 54, in ImportError: cannot import name 'text_encoding' from 'io' (unknown location) If I understand well, I'll have to write a customized startup script, with correct path (not pointing to my c:\python\lib) so that QGis can start using the included Python interpreter (and not my system-wide one). But I didn't find how to achieve that. Later, I think I'll have to write some QGis Python code. Then, I'll need to run it in "developer" mode : being able to put the source code in a git repository, edit the code in PyCharm, and run it. Any clues are welcome. Thank you in advance. Kind regards ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info:https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user -- Johannes Kröger / GIS-Entwickler/-Berater - Aufwind durch Wissen! Web-Seminare und Online-Schulungen bei derwww.foss-academy.com - WhereGroup GmbH c/o KK03 GmbH Lange Reihe 29 20099 Hamburg Germany Tel: +49 (0)228 / 90 90 38 - 36 Fax: +49 (0)228 / 90 90 38 - 11 johannes.kroe...@wheregroup.com www.wheregroup.com Geschäftsführer: Olaf Knopp, Peter Stamm Amtsgericht Bonn, HRB 9885 --- ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] Running QGis on a machine with Python 3.11 and PyCharm ?
Hi Toussaint, I am not a hard-core developer, but I script/code whenever I can automate a procedure, so: * It is my understanding that QGIS is developed/maintained in the QT environment - so go that way rather than PyCharm if you plan to dabble in QGIS development. Perhaps one of the devs that lurk on this user list will add to this comment of mine. * Get on to QGIS-dev as well - you might find some better guidance there, for PyCharm and other python scripting issues. I will try to find time to set up QGIS and PyCharm on my laptop in the next day or so - *_but in the meantime, google_* "pycharm with qgis" - there are about a billion articles and videos that come up. Oh!, Yes!, I am exaggerating. :-) Regards, Zoltan On 2023/06/12 10:06, Toussaint OTTAVI via QGIS-User wrote: Hi Zoltan, Thank you in advance for your help. For now, I didn't manage to find a suitable configuration by setting paths and environment variables in a startup ".bat" file. QGis still tries to load things from my system-wide Python folder (c:\python), even if no path or env variable points to it. Then, it fails. The only workaround I found is a bit rough : rename my c:\python folder to c:\python.bak, run QGis, then rename back to the original name ! Of course, this prevents from using QGis at the same time with PyCharm or other Python stuff, and is not an acceptable solution on the long term. Even if I don't have the skills to dive into QGis source code for now, I may try to play around with some simple plugins. Then, wouldn't it be a better idea to install QGis in "developer" mode, by cloning / forking the GitHub repo ? Any suggestions are welcome. Kind regards. Le 09/06/2023 à 22:25, Zoltan a écrit : Hi, I seem to remember that pycharm website provides help on using pycharm with qgis, so don't mess with your existing installations of python. The gist of it is that you add the pycharm startup to the end of the bat file that qgis provides for setting up all the env variables. Starting pycharm from the Taskbar will not set these environment for you so use the edited bat file I describe above. There might also be a way in your pycharm venv to pre set these env vars. I have a new laptop which I have not yet set up for this but if you are still stuck tomorrow, I'll set mine up and let you know what works. Regards Zoltan ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info:https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user -- = Zoltan Szecsei GPrGISc 0031 Director, Geograph (Pty) Ltd. GIS and Photogrammetric Services Cape Town, South Africa. Mobile: +974-5058-8729 (Signal, not WhatsApp) +27-83-6004028 (Signal, not WhatsApp) www.geograph.co.za = ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] Running QGis on a machine with Python 3.11 and PyCharm ?
Hi Zoltan, Thank you in advance for your help. For now, I didn't manage to find a suitable configuration by setting paths and environment variables in a startup ".bat" file. QGis still tries to load things from my system-wide Python folder (c:\python), even if no path or env variable points to it. Then, it fails. The only workaround I found is a bit rough : rename my c:\python folder to c:\python.bak, run QGis, then rename back to the original name ! Of course, this prevents from using QGis at the same time with PyCharm or other Python stuff, and is not an acceptable solution on the long term. Even if I don't have the skills to dive into QGis source code for now, I may try to play around with some simple plugins. Then, wouldn't it be a better idea to install QGis in "developer" mode, by cloning / forking the GitHub repo ? Any suggestions are welcome. Kind regards. Le 09/06/2023 à 22:25, Zoltan a écrit : Hi, I seem to remember that pycharm website provides help on using pycharm with qgis, so don't mess with your existing installations of python. The gist of it is that you add the pycharm startup to the end of the bat file that qgis provides for setting up all the env variables. Starting pycharm from the Taskbar will not set these environment for you so use the edited bat file I describe above. There might also be a way in your pycharm venv to pre set these env vars. I have a new laptop which I have not yet set up for this but if you are still stuck tomorrow, I'll set mine up and let you know what works. Regards Zoltan ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] Running QGis on a machine with Python 3.11 and PyCharm ?
Hi, I seem to remember that pycharm website provides help on using pycharm with qgis, so don't mess with your existing installations of python. The gist of it is that you add the pycharm startup to the end of the bat file that qgis provides for setting up all the env variables. Starting pycharm from the Taskbar will not set these environment for you so use the edited bat file I describe above. There might also be a way in your pycharm venv to pre set these env vars. I have a new laptop which I have not yet set up for this but if you are still stuck tomorrow, I'll set mine up and let you know what works. Regards Zoltan Sent from Blue On 09 Jun 2023, 22:45, at 22:45, Toussaint OTTAVI via QGIS-User wrote: > > >Le 09/06/2023 à 18:11, Toussaint OTTAVI via QGIS-User a écrit : >> If I understand well, I'll have to write a customized startup script, > >> with correct path (not pointing to my c:\python\lib) so that QGis can > >> start using the included Python interpreter (and not my system-wide >> one). But I didn't find how to achieve that. > >For now, the only workaround I found to start QGis is to remove >completely my system-wide "c:\python" directory. >Trying to configure path and PYTHONPATH with priority to the QGis >folder >(such as the included .bat files do) does not work. Doing so, and using > >SysInternals Process Monitor, we can see it still tries to load things >from my "c:\python" directory, and it fails because there are >incompatible library versions. > >Of course, removing my system-wide Python installation is not an >acceptable workaround ;-) > >How to force QGis to use only the Python stuff in its folders and >sub-folders ? Virtualenv ? > > > >___ >QGIS-User mailing list >QGIS-User@lists.osgeo.org >List info: https://lists.osgeo.org/mailman/listinfo/qgis-user >Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user ___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
Re: [Qgis-user] Running QGis on a machine with Python 3.11 and PyCharm ?
Le 09/06/2023 à 18:11, Toussaint OTTAVI via QGIS-User a écrit : If I understand well, I'll have to write a customized startup script, with correct path (not pointing to my c:\python\lib) so that QGis can start using the included Python interpreter (and not my system-wide one). But I didn't find how to achieve that. For now, the only workaround I found to start QGis is to remove completely my system-wide "c:\python" directory. Trying to configure path and PYTHONPATH with priority to the QGis folder (such as the included .bat files do) does not work. Doing so, and using SysInternals Process Monitor, we can see it still tries to load things from my "c:\python" directory, and it fails because there are incompatible library versions. Of course, removing my system-wide Python installation is not an acceptable workaround ;-) How to force QGis to use only the Python stuff in its folders and sub-folders ? Virtualenv ?___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
[Qgis-user] Running QGis on a machine with Python 3.11 and PyCharm ?
Hi, I'm new to QGis. I'm trying to install latest version (3.28.7 LTR) on my machine. It does not run. The startup window shows during a few seconds, then, nothing. I tried several older versions. None of them wants to start. The exception is 3.14, which starts, and works perfectly. On my machine, I already have a Python 3 installed (currently, 3.11.1), on absolute path C:\Python, PYTHONPATH system variable pointing to it, and system path, too. I also have PyCharm installed. I think this may be the cause of my problem. I noticed the included interpreter (C:\Program Files\QGIS 3.28.7\bin\python.exe) does not start at all, with Python error : File "C:\Python\Lib\io.py", line 54, in ImportError: cannot import name 'text_encoding' from 'io' (unknown location) If I understand well, I'll have to write a customized startup script, with correct path (not pointing to my c:\python\lib) so that QGis can start using the included Python interpreter (and not my system-wide one). But I didn't find how to achieve that. Later, I think I'll have to write some QGis Python code. Then, I'll need to run it in "developer" mode : being able to put the source code in a git repository, edit the code in PyCharm, and run it. Any clues are welcome. Thank you in advance. Kind regards___ QGIS-User mailing list QGIS-User@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user