New to QGIS and Python. Have QGIS installed and working great on Windows, want to install and use Docutils — Python Documentation Utilities (presumably all simple and small .py programs).
I see that QGIS has a Python Console built in. Do I just use that? What is the command line to run install.py?
QGIS obviously installed Python. However it looks like the customary path variables were not set during the QIS install, such that Python can be run from a windows command (cmd.exe) window.
That seems to be the task here, so I proceed to try to enable Python to run independent of QGIS.
First I search for python.exe. I find it at:
C:\Program Files\QGIS Lyon\bin
So I set the windows path variable to include that.
After searching (and a lot of confusion as to where the Python distribution actually is, is it standard, or is it custom, questions as to how libraries, etc are laid out, and noting its all installed "underneath" C:\Program Files\QGIS Lyon) so it appears custom(?) Will I break that by using it for "generalized" Python programs?
I try the following environmental values:
PYTHONPATH
C:\Program Files\QGIS Lyon\apps\Python27\Lib
PYTHONHOME
C:\Program Files\QGIS Lyon\bin
Have no idea if those are even close to correct.
I then run the install for docutils
C:\Users\rick\Desktop\docutils-0.12>python install.py
Program starts, but then errors per below.
Seems like a "documentation utility" should be a snap to install. Plus there probably a straightforward way to run Python programs independent of QGIS? I also note an additional install of Python with Inkscape (a vector drawing program used in the QGIS training manual.) So already two installs of Python on the system already. (Correction, three installs. FWTools has yet another Python install.)
If a user wants to run Python programs (such as docutils and other small learning programs) should they download a fresh Python "stand alone" install? (looks like on this machine that would be the 4th install?)
errors
C:\Users\rick\Desktop\docutils-0.12>python install.py
This is a quick & dirty installation shortcut. It is equivalent to the
command::
python setup.py install
However, the shortcut lacks error checking and command-line option
processing. If you need any kind of customization or help, please use
one of::
python setup.py install --help
python setup.py --help
Traceback (most recent call last):
File "install.py", line 27, in
dist.run_commands()
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\dist.py", line 95
3, in run_commands
self.run_command(cmd)
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\dist.py", line 97
2, in run_command
cmd_obj.run()
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\command\install.p
y", line 575, in run
self.run_command(cmd_name)
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\cmd.py", line 326
, in run_command
self.distribution.run_command(command)
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\dist.py", line 97
2, in run_command
cmd_obj.run()
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\command\install_l
ib.py", line 97, in run
outfiles = self.install()
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\command\install_l
ib.py", line 115, in install
outfiles = self.copy_tree(self.build_dir, self.install_dir)
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\cmd.py", line 377
, in copy_tree
dry_run=self.dry_run)
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\dir_util.py", lin
e 139, in copy_tree
mkpath(dst, verbose=verbose)
File "C:\Program Files\QGIS Lyon\apps\Python27\Lib\distutils\dir_util.py", lin
e 76, in mkpath
"could not create '%s': %s" % (head, exc.args[-1]))
distutils.errors.DistutilsFileError: could not create 'C:\Program Files\QGIS Lyo
n\bin\Lib': Access is denied
Best Answer
Don't make life more complicated, it's much easier:
So:
1) You can use the Python console as a classic Python shell using exclusively the QGIS Python with PyQGIS and the other modules installed by default, as Numpy (in C:\Program Files\QGIS Lyon\apps\Python27\Lib\site-packages) = the PYTHONPATH of the QGIS Python. You can control it by typing in the console
2) if you want to install an other Python module as Docutils, the problem is that Setuptools (setup.py, easy_install) or pip are not installed by default, even with the OSGeo4W installer, -> look at How to install 3rd party python libraries for QGIS on Windows?, QGIS Standalone and the Python Modules, Installing Python setuptools into OSGeo4W Python or OSGeo4W External Python Packages
At this stage, you have a full Windows Python version: you can use setup.py, easy_install or pip to install new modules, you don't need to fix the PYTHONPATH and you can use PyQGIS and the other modules installed in the QGIS site_packages folder
If you want to use other simple modules installed in other Python versions, simply use:
3) But if you want to use PyQGIS from outside (in other version of Python), it is another problem: search for on the GIS SE or the Web (as in Configure PyScripter to use with QGIS (and still use arcpy) on Windows, Standalone applications using QGIS and environment variables, and many others)