

- #Python 2to3 windows batch script example update#
- #Python 2to3 windows batch script example upgrade#
- #Python 2to3 windows batch script example download#
I was struggling a bit with the environmental variables to get it working, and ended up using a great batch script form StackExchange: Then we need to recompile the icon and ui for Python3 and QT5. Then we can edit the metadata.txt to QGIS 3: So I edit it to: QgsProject.instance().addMapLayer(vl) Looks like QgsMapLayerRegistry was moved to QgsProject. There is a list of API breaks between QGIS 2 and QGIS 3 at: QgsMapLayerRegistry.instance().addMapLayer(vl)
#Python 2to3 windows batch script example update#
It takes a while to update the interpreter. Then from File> Settings> Project:> Project Interpreter> Set to “C:\OSGeo4W64\apps\Python36\python.exe” To: start /d "C:\Program Files\JetBrains\P圜harm Community Edition 2017.2.1\bin\" pycharm64.exe I changed the final line of: "%PYTHONHOME%\python" %* So copying the “python-qgis-dev.bat” file from: I created a bat file that launched P圜harm with the QGIS dev environmental variables. These changes can be applied with –w flag: python 2to3 C:\path_to_plugin\QGIS_Multi_Ring_Buffer -wįor the next step I booted up my favourite IDE P圜harm.

Running the 2to3 script again looked ok, with a number of changes required.

I ended up expanding my other import from QtCore to: from PyQt4.QtCore import QSettings, QTranslator, qVersion, QCoreApplication, QVariant, Qt NameError: global name 'Qt' is not defined NameError: global name 'QVariant' is not defined I commented out the line for the plugin in QGIS 2.8, booted up QGIS 2.8 and tried running the plugin. Was impossible to convert with the tool, since I was not 100% sure what I needed from the QtCore library (I was young when I wrote the plugin). So my plugins line of: from PyQt4.QtCore import * RefactoringTool: Cannot handle star imports. My first run resulted in many lines of: RefactoringTool: Line 31: could not convert: from PyQt4.QtCore import * This will print out changes that need to be made to convert from QGIS2 to QGIS3. Then we can run the 2to3 script from the OSGeo4W console (cd to the folder you extracted the script to): python 2to3 C:\path_to_plugin\QGIS_Multi_Ring_Buffer
#Python 2to3 windows batch script example download#
We can download just the scripts folder using the following link:Įxtract that into a location of your choice. The qgis2to3 packages can be found on pip now: There is a conversion script for QGIS plugins provided by the QGIS devs in the main repo. There is a short guide by the QGIS dev team that is a good starting point at:īut I had not done any development on these plugins for a while so a more step by step guide was useful, so hopefully, write the guide for the first plugin and follow it step by step for the second.īefore we start we will need to insure a couple of extras are installed through the OSGeo4w Installer:
#Python 2to3 windows batch script example upgrade#
I have two plugins in the QGIS plugin repository, and with the release of QGIS 3 looming it was time to upgrade them for QGIS 3. Updating A Plugin From QGIS 2 to QGIS 3 | GIS for Thought Updating A Plugin From QGIS 2 to QGIS 3 GISforThought.
