2

My QGIS installation has python 2.7 by default. I am not able to update this python 2.7 to an upper version of python ( e.g. python 2.7.11). I searched the web, however, I do not want to make changes without being sure. Is it ok if I install the new python and set the PYTHONPATH environment variable as below:

set PYTHONPATH=c:\qgispath\python 

Edit: I mean to update python 2.7 to 2.7.11 and not 2.11 ( Sorry for the typo). I updated the question.

  • 1
    Do you mean Python 2.7.11 ? – Midavalo Mar 20 '18 at 3:24
  • 2
    Python 2.7.11 was released in 2015, the latest release of the 2.7 series is 2.7.14. That said, you probably can upgrade to higher patch releases (Python uses semantic versioning where version X.Y.Z = major version . minor point release . patch). It's not simple with QGIS though, just setting PYTHONPATH won't do and there's not really any reason to do so unless there is a specific bug in an earlier Python 2.7.x that is fixed in Python 2.7.x+1 or later. – user2856 Mar 20 '18 at 3:58
  • Yes, I mean to update python 2.7 to 2.7.11 (NOT 2.11 , sorry for the typo) Or even updating to 2.7.14. I need to update the python for QGIS because it throws an error (i.e. AttributeError: 'NoneType' object has no attribute 'split' ) and it is advised to update python to solve the problem. – OSMuser Mar 20 '18 at 9:45
3

No you can't update the version of python that is shipped with QGIS. We ship our own version (it's just standard) but included as part of the install package.

Your error sounds like a bug in the code more than an issue with the Python version.

  • Do you mean "...can't update the version of Python..."? Combine this with the fact that the pip version that ships with QGIS 2.18 no longer works with pypi (i.e. cannot install/upgrade from pypi due to TLS version restrictions) see my post at link, this severely limits the use of any tools/extensions for QGIS 2.18 that rely on additional Python packages. – David Apr 16 '18 at 23:00
  • Our solution has been to install Python 2.7.15 in a new folder, then use pip to install the libraries we need for QGIS 2.18.xx. Then the libraries are deleted in the QGIS site-packages folder, replaced with the ones generated in Python 2.7.15. Hacky, yes, but it works for the present. It would be nice to migrate to QGIS 3, but that is a ways off for us at this point. – Rudy Stricklan May 4 '18 at 3:33
  • @RudyStricklan can you elaborate on the "hacky" method? I tried installing pymongo into a conda virtual environment and then moving the pymongo folder from the site-packages folder in the virtual environment into the QGIS site-packages folder, but had no luck (couldn't install a plug-in that depended on it, then verified that it didn't work by trying to import it). Does this only work for updating packages? Are there some config files or something I need to update to include the copied library? – Albert Rothman Aug 6 '18 at 21:49
0

@Albert Rothman What we're doing is doing a pip install of the package using a standalone version Python 2.7.15 that was installed independently of QGIS (in our case, in folder 'c:\python_2715'). Then the new folders that are created and populated in the c:\python_2715\Lib\site-packages via the pip install are copied and pasted into the QGIS Python library folder, in our case 'C:\Program Files\QGIS 2.18\apps\Python27\Lib\site-packages'. A recent example was 'pip install boto' which resulted in folders 'boto' and 'boto-2.48.0.dist-info' being produced, and then copied over to 'C:\Program Files\QGIS 2.18\apps\Python27\Lib\site-packages'. Inelegant (and maybe there's something fundamentally wrong with this), but it seems to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.