1

I opened QGIS, started a new project, and loaded rasters. Then I saved the project to a folder I had already created. I got the following error message. The same exact message appeared when I closed QGIS, then booted it up again, and opened the same project!

An error occured during execution of following code:
sys.path.append('/Users/greg/Documents/Greg's stuff/GIS/QGIS_projects_I_made')


  File "", line 1
    sys.path.append('/Users/greg/Documents/Greg's stuff/GIS/QGIS_projects_I_made')
                                                ^
SyntaxError: invalid syntax

Python version: 2.7.2 (default, Oct 11 2012, 20:14:37) [GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)]

QGIS version: 2.0.1-Dufour 'Dufour', f738351

Python path: ['/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing', '/Applications/QGIS.app/Contents/MacOS/../Resources/python', '/Users/greg/.qgis2/python', '/Users/greg/.qgis2/python/plugins', '/Applications/QGIS.app/Contents/MacOS/../Resources/python/plugins', '/Library/Frameworks/SQLite3.framework/Versions/B/Python/2.7', '/Library/Frameworks/GEOS.framework/Versions/3/Python/2.7', '/Library/Python/2.7/site-packages/numpy-override', '/Library/Frameworks/GDAL.framework/Versions/1.10/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/Applications/QGIS.app/Contents/Resources/python/plugins/fTools/tools']

2
  • Are you able to save to any other directory? If so, then my initial thought would be the problem is related to the apostrophe in the file path: Greg's stuff. Most programs can get past spaces in a file path these days, but I think an apostrophe may be pushing it too far. Dec 17, 2013 at 0:24
  • 2
    In fact, the marker in the error is pointing to exactly what my previous comment alluded to. The apostrophe is acting as the end of the string, thus creating a syntax error. Try removing that from the directory name and trying again. Dec 17, 2013 at 0:26

1 Answer 1

6

Something in fTools/tools is trying to add the project folder to PYTHONPATH but Python is breaking on the ' in your path.

Simply remove the ' the folder name.

2
  • It should be possible to escape it too, but I don't know how to do that in Python.
    – AndreJ
    Dec 17, 2013 at 5:07
  • I would like to note that I have followed the advice given, changing the name of my file folder by removing the apostrophe. This works for QGIS file naming, but anyone else following this should know that it can cause trouble for other applications which already "know" the old file folder name.
    – Catlike
    Dec 20, 2013 at 2:02

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.