ptrv / gpx2spatialite

GNU General Public License v3.0
23 stars 8 forks source link

Syntax Error while trying to create database using gpx2spatialite_create_db #20

Closed curious000cat closed 9 years ago

curious000cat commented 9 years ago

Hi Everyone!

I'm kind of new to python and I'm using windows not linux so I'm confused over this:

image

I'm trying to follow the example to load a bunch of gpx files unto a spatialite dbase as shown in: http://gis.stackexchange.com/questions/32618/how-to-build-a-geographic-database-of-gps-logs and so I typed in:

gpx2spatialite_create_db MyGPXArchive.db

but I keep getting a syntax error which i feel is really the result of a path assignment error.

What is PATH=$PATH:$HOME/.local/bin on Windows 8? I already have C:\Python27;C:\Python27\Scripts; in my environment path. I also tried C:\Users\User\AppData\Roaming.local\bin but still no luck.

image

I hope you can help me out..thanks in advance!

Mitch

curious000cat commented 9 years ago

I updated my post (above) as C:\Users\User\AppData\Roaming.local\bin but the backslash still does not appear so I added a new comment..

belasco commented 9 years ago

Hi Mitch, Thanks for your interest in our script and sorry that you're facing problems. Although I'm one of the people who worked on this script, I'm not a programmer so I might not be able to pinpoint your troubles. Added to this, I'm on Linux so YMMV. I install gpx2spatialite from PyPi using pip / easy_install. This puts it into /usr/local/bin/ This means I can open a terminal window, then WITHOUT going into Python, just directly type gpx2spatialite or gpx2spatialite_create_db I hope this solves things for you Dan

ptrv commented 9 years ago

Hi Mitch,

I think C:\Python27;C:\Python27\Scripts; is the correct PATH entry on Windows but I don't know whether calling the script directly will work. Try calling the following from the command line:

python gpx2spatialite_create_db ...

or even specifying the full script path

python C:\Python27\Scripts\gpx2spatialite_create_db ...

Do not call the script from within the python prompt (the prompt you get when you run python), it won't work for sure.

Maybe it might also help if you set your PYTHONPATH to C:\Python27\Scripts\Lib\site-packages

ptrv commented 9 years ago

@curious000cat Unfortunately we are all guessing here since we are Linux or Mac users.

@johnjohndoe Did you try gpx2spatialite on Windows?

johnjohndoe commented 9 years ago

No. But I probably can try it tomorrow at work where I have a Windows installation to play around with.

ptrv commented 9 years ago

@johnjohndoe Great, thanks! It would be really nice to have instructions also for Windows.

curious000cat commented 9 years ago

Hi everyone! Thanks for replying. I haven't gone back to this issue yet so I haven't tried out the suggestions given. Ultimately, I would actually like to use the [ gpx2spatialite -d db.sqlite -u user file.gpx ] in a subprocess to be called from within a python script. This is for a school project and I'm currently working on the GUI part. I usually do an initial testing (with the cmd prompt) of modules to use so that I don't have to incorporate the lines immediately into my script. I'll let you know what works for me as soon as I get back to the import gpx files part. Thanks again!

johnjohndoe commented 9 years ago

There are couple of requirements which must be met on Windows. I tested the following on Windows 7 Professional 64bit.

  1. Python 2.7 is installed in C:\Python27
  2. Python directories must be set up in the PATH variable which includes: C:\Python27\;C:\Python27\Scripts\. The status of the PATH variable can be checked by executing the set command in a new command line window.
  3. pip must be installed on Windows - there is documentation on how install pip for various Python versions available.
  4. Installation of Python packages on Windows should be without the --user parameter. Otherwise the package will be installed in the following directory:

    C:\Users\USERNAME\AppData\Roaming\Python27\

    This directory is not recognize by the PATH variable. Therefore use the following installations commands:

    C:\> pip install gpxpy
    C:\> pip install gpx2spatialite

    This installs the package in the expected directory. You should find the following files:

    C:\Python27\Scripts\gpx2spatialite
    C:\Python27\Scripts\gpx2spatialite_citydefs
    C:\Python27\Scripts\gpx2spatialite_create_db
    C:\Python27\Scripts\gpx2spatialite_updatelocs

Nonetheless, I was not able to run gpx2spatialite from the shell. What appears strange to me is that gpx2spatialite is not actually a Windows executable as gpx2spatialite.exe would indicate. I guess @ptrv can explain that.

ptrv commented 9 years ago

@johnjohndoe Thanks for trying on Windows. I installed a virtual box Windows to try. I got the scripts to work but it requires a few steps.

C:\Users\peter>python C:\Python27\Scripts\gpx2spatialite_create_db test.db
ptrv commented 9 years ago

We have to think about how to bundle all required libraries in one executable for Windows. I will create a issue.

ptrv commented 9 years ago

See https://github.com/ptrv/gpx2spatialite/issues/22

ptrv commented 9 years ago

@curious000cat I pushed some improvemets for Windows to the https://github.com/ptrv/gpx2spatialite/tree/one-script branch. Check install instruction here: https://github.com/ptrv/gpx2spatialite/tree/one-script#windows

Until the branch is not merged you have to install gpx2spatalite directly from that branch:

pip install git+https://github.com/ptrv/gpx2spatialite.git@one-script

Notice that there is now only one script and all other functionality is a subcommand. See https://github.com/ptrv/gpx2spatialite/tree/one-script#usage for more information

curious000cat commented 9 years ago

Hi Everyone!

I just started working on this again now and I followed the instructions as given. The gpx2spatialite process now seems to be activated but this time though, the error said something about a DLL load fail for _sqlite3.

I pasted the sqlite3.dll as well as sqlite3.def from the sqlite-dll-win32-x86-3080704.zip I downloaded from http://www.sqlite.org/download.html into my C:\Python27\Scripts. I didn't get to overwrite anything because there was none there. There was no DLLs folder inside Scripts either unlike the C:\Python27\Scripts\DLLs mentioned so I created a new folder named DLLs and copied the sqlite3.dll and sqlite3.def into that. I have a C:\Python27\DLLs with an sqlite3.dll. This one I renamed to ORIG_sqlite3.dll then I pasted the new sqlite3.dll and sqlite3.def in its place.

So now I have the new sqlite3.dll and sqlite3.def in:

  1. C:\Python27\DLLs
  2. C:\Python27\Scripts
  3. C:\Python27\Scripts\DLLs

and the error is now:

image

I was able to create databases yesterday with the old sqlite3.dll by calling it directly within the script. I'll put back the old one in all of the said folders, keep trying for a couple more days, maybe reinstall python or something then move-on. I'm using Windows 8 & Python 2.7.8 both 64-bit so I'm not sure, maybe that's also part of the incompatibility issue.

Anyway, I really appreciate your help. Merry Christmas in advance =)

Mitch

ptrv commented 9 years ago

First of all you need a 32bit Python installation. The downloaded sqlite3.dll file should replace the dll in C:\Python27\DLLs and the mod_spatialite dlls (which are also 32bit) should go into C:\Python27\Scripts right next to the gpx2spatialite scripts.

And also reinstall your outdated version 0.5 gpx2spatialite with version 0.6.1 or the developmment version.

pip uninstall gpx2spatialite
pip install git+https://github.com/ptrv/gpx2spatialite.git@one-script
curious000cat commented 9 years ago

Ok I'll do that. Thanks again!

curious000cat commented 9 years ago

Hi, I checked out the difference between running a 32bit versus 64bit Python and it was mentioned that performance difference would not really be an issue unless performing large computations. I will be learning how to process lidar data using python and will eventually use some of the codes from this particular school project. So to avoid editing code due to version issues, I'll keep the 64bit python. I'll be considering this question as answered. Thanks again!