-
Notifications
You must be signed in to change notification settings - Fork 68
Getting Started as a Developer in Python 2.7 (Anaconda version)
These instructions are not current. Even if these steps still work, they will not include QGIS functionality. See the other page for the currently recommended: https://github.com/USEPA/SWMM-EPANET_User_Interface/wiki/Getting-Started-as-a-Developer
Windows is the original development platform and is the one documented here. If you are developing on another platform, please use these instructions as a starting point and share with us the particular steps needed on your platform.
There are several options available, some with command-line access and others with Explorer shell integration or stand-alone GUIs. The PyCharm development environment, which we recommend, can access git if it is installed from:
https://git-scm.com/downloads
https://www.jetbrains.com/pycharm/ This is the recommended development environment, but you can use your favorite Python development environment.
-
Visit https://www.qgis.org/en/site/forusers/download.html and under "For Advanced Users" get the OSGeo4W Network Installer (64 bit)
-
Run the installer and choose "Advanced Install" then "Install from Internet"
-
Root Directory: C:\OSGeo4W64 (adjust instructions below if not) and "Install For All Users". Allow it to "Create icon on Desktop" and "Add icon to Start Menu"
-
Local Package Directory: C:\OSGeo4W64\Temp Start menu name: the default is fine.
-
Select Your Internet Connection: probably "Direct Connection" or consult your local computer support.
-
Choose a Download Site: select the first site on the list if it is not already selected.
-
Select Packages: (Note: for some packages there is a -dev version also available that you do not want.) In command line utilities, select: python-core, python-tools. python-tcltk, setup, shell. In desktop, select qgis-full. In libs, choose gdal-filegdb and setuptools.
-
The next step will warn that additional packages need to be installed. Make sure "Install these packages" is selected, press Next, agree to several licenses, then wait a while for all the parts to be downloaded and installed.
-
In Control Panel/System/Advanced/Environment Variables/User, set some variables: (Note: PATH will likely already have a value. You can keep this value by putting the new value first, then a semicolon, then the existing value. Remove any existing parts of the path that reference Anaconda or Python.)
OSGEO4W_ROOT=C:\OSGeo4W64
QGIS=C:\OSGeo4W64\apps\qgis
QGIS_PREFIX_PATH=C:\OSGeo4W64\apps\qgis
PATH=C:\OSGeo4W64\bin;C:\OSGeo4W64\apps\qgis\bin
PYTHONHOME=C:\OSGeo4W64\apps\Python27
PYTHONPATH=C:\OSGeo4W64\apps\qgis\python -
NumPy and SciPy are not correctly installed by the default pip commands, so they need special steps: Download NumPy as a package from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy get the latest numpy+mkl that has cp27 and win_amd64 in the file name, for example: numpy-1.11.1+mkl-cp27-cp27m-win_amd64.whl
-
Download SciPy as a package from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy get the latest scipy that has cp27 and win_amd64 in the file name, for example: scipy-0.18.0-cp27-cp27m-win_amd64.whl
-
Download Pandas as a package from: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pandas get the latest that has cp27 and win_amd64 in the file name, for example: pandas-0.19.0-cp27-cp27m-win_amd64.whl
-
Open an OSGeo4W Shell using the icon the installer created on the desktop. Ignore insecure platform warnings and issue the following commands:
python -m pip install --upgrade pip
pip install qtconsole
pip install enum34
pip install matplotlib --upgrade
It is fine if the following two uninstall commands fail:
pip uninstall numpy
pip uninstall scipy
pip install numpy- filename downloaded above.whl
pip install scipy- filename downloaded above.whl pip install pandas- filename downloaded above.whl
Start PyCharm, click “Check out from Version Control”, choose GitHub.
Log in and choose whether to save your password or use a master password.
Repository URL: https://github.com/USEPA/SWMM-EPANET_User_Interface.git
Directory: choose the parent directory to put the new directory in.
Directory Name: recommend leaving it as the default: SWMM-EPANET_User_Interface
Press Clone.
Answer Yes when asked whether to open the directory.
If you do not see the project files, use View/Tool Windows/Project.
This is the latest release version. For the development version, find “Git: master” in the status bar in the lower right part of PyCharm, click it, choose another branch such as origin/dev or origin/dev-ui, “Checkout as new local branch”,
Enter name of new branch: keep the default name
OK
- In PyCharm, if you do not see the project files, use View/Tool Windows/Project.
- In the Project view, right-click folder "src" and choose "Mark Directory As"/"Sources Root"
- Right-click the top item in the Project view "SWMM-EPANET_User_Interface..." and "Mark Directory As"/"Sources Root"
- File/Settings/Build, Execution, Deployment/Console/Python Console: check "Add source roots to PYTHONPATH", press OK.
- File/Settings/Project:.../Project Interpreter: choose C:\OSGeo4W64\bin\python.exe, press OK.
- Wait while PyCharm searches through the Python folders. (Status is in bottom bar of PyCharm.)
- This can take a long time. You can look at code while this happens, but need to wait to run after it completes.
- In the Project window under src\ui Right-click “SWMM/frmMainSWMM.py” or EPANET/frmMainEPANET, and choose Debug.
- Green “Play” button runs the last thing you chose to run, “Bug” button next to it runs in debug mode.
Below are specialized instructions for unusual situations:
If you are going to generate documentation with Doxygen:
The additional package doxypypy is recommended. (See https://github.com/Feneric/doxypypy.):
pip install doxypypy
Create batch file ~\Anaconda2\Scripts\py_filter.bat containing one line:
doxypypy -a -c %1