Seite 1 von 1

overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Montag 9. Oktober 2017, 23:18
von dilbert
guten Abend liebe Community,

will o.g. thin wrapper installieren: overpass-api-python-wrapper

https://github.com/mvexel/overpass-api-python-wrapper

was ich in eric bekomme ist folgendes :

Code: Alles auswählen

Python 3.4.6 (default, Mar 22 2017, 12:26:13) [GCC] auf linux-jnmx, Standard
>>> $ pip install overpass
  File "<stdin>", line 1
    $ pip install overpass
    ^
SyntaxError: invalid syntax
>>> 
>>> 
>>> $ sudo apt-get install libgeos-c1 libgeos-3.4.2
  File "<stdin>", line 1
    $ sudo apt-get install libgeos-c1 libgeos-3.4.2
    ^
SyntaxError: invalid syntax
>>> 

was läuft hier falsch!? Freue mich von Euch zu hoeren.

Vg

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Montag 9. Oktober 2017, 23:28
von __deets__
Das du Shell Kommandos im interaktiven Python prompt ausführen willst. Das geht nicht. Starte eine Shell & probier’s da.

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Montag 9. Oktober 2017, 23:45
von dilbert
hallo deets

viellen dank!!!

Code: Alles auswählen

linux-jnmx:~ # pip install overpass
Collecting overpass
  Downloading overpass-0.5.6.tar.gz
Requirement already satisfied (use --upgrade to upgrade): requests>=2.3.0 in /usr/lib/python3.4/site-packages (from overpass)
Collecting geojson>=1.0.9 (from overpass)
  Downloading geojson-2.3.0-py2.py3-none-any.whl
Installing collected packages: geojson, overpass
  Running setup.py install for overpass
Successfully installed geojson-2.3.0 overpass-0.5.6
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
linux-jnmx:~ # 
jetzt läufts

Code: Alles auswählen

linux-jnmx:~ # pip install --upgrade pip
Collecting pip
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 217kB/s 
Installing collected packages: pip
  Found existing installation: pip 7.1.2
    Uninstalling pip-7.1.2:
      Successfully uninstalled pip-7.1.2
Successfully installed pip-9.0.1
linux-jnmx:~ # 

wenn ich nun jetzt das Beispiel durchspiele - hier https://github.com/mvexel/overpass-api-python-wrapper

dann geb ich untenstehenden code in eric in die ide ein ;

Code: Alles auswählen

import overpass
api = overpass.API()
response = api.Get('node["name"="Salt Lake City"]')
- es sollte - wie oben auf der Page hier vermerkt ist https://github.com/mvexel/overpass-api-python-wrapper

folgendes Ergebnis zeitigen - ...:;

Code: Alles auswählen

print [(feature['tags']['name'], feature['id']) for feature in response['elements']]
[(u'Salt Lake City', 150935219), (u'Salt Lake City', 585370637), (u'Salt Lake City', 1615721573)]
das funktioniert nicht -

mache ich hier etwas falsch!?

vg

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Dienstag 10. Oktober 2017, 07:11
von Sirius3
@dilbert: was heißt, "funktioniert nicht"? Was passiert? Was wird genau auf dem Bildschirm ausgegeben?

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Dienstag 10. Oktober 2017, 11:22
von dilbert
hallo Sirius,

vielen Dank für die schnelle Antwort. Bin grad nicht vor dem Linux-notebook ( an dem ich das gestern abend gemacht hab. ) Meld mich heute abend.
VG dilbert

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Dienstag 10. Oktober 2017, 22:23
von dilbert
hallo und guten Abend,


also es passiert praktisch gar nix: ich geb das hier in die shell ein:

Code: Alles auswählen

import overpass
api = overpass.API()
response = api.Get('node["name"="Salt Lake City"]')

und nix passiert .....

:)

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Dienstag 10. Oktober 2017, 22:27
von Sirius3
und wo ist das

Code: Alles auswählen

print [(feature['tags']['name'], feature['id']) for feature in response['elements']]
?

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Dienstag 10. Oktober 2017, 22:35
von kbr
@dilbert: Ich hatte schon den Verdacht, dass Du 'print [...' etc. als Output erwartet hast. Das ist aber der nächste Programmcode, der auszuführen ist, um an die verschiedenen Salt Lake Cities zu kommen.

Du musst Dir schon ein wenig Verständnis von Python aneignen, um damit zu arbeiten. Sonst bist Du immer im Blindflug.

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Mittwoch 11. Oktober 2017, 05:56
von dilbert
hallo und guten Morgen ,

[ vorweg: muss gleich aus dem Haus - aber das hier hab ich noch versucht - ]

Danke für die Tipps - wenn ich das so eingebe komm ich zu folgendem Ergebnis.

Code: Alles auswählen

Python 3.4.6 (default, Mar 22 2017, 12:26:13) [GCC] auf linux-jnmx, Standard
>>> import overpass
>>> api = overpass.API()
>>> response = api.Get('node["name"="Salt Lake City"]')
>>> 
>>> print [(feature['tags']['name'], feature['id']) for feature in response['elements']]
  File "<stdin>", line 1
    print [(feature['tags']['name'], feature['id']) for feature in response['elements']]
                                                      ^
SyntaxError: invalid syntax
>>> [(u'Salt Lake City', 150935219), (u'Salt Lake City', 585370637), (u'Salt Lake City', 1615721573)]
[('Salt Lake City', 150935219), ('Salt Lake City', 585370637), ('Salt Lake City', 1615721573)]
>>> 

ich werde mal nachsehen wo ich den Syntax-Error herrührt
^
SyntaxError: invalid syntax


vb dilbert

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Mittwoch 11. Oktober 2017, 08:09
von Sirius3
@dilbert: wie kbr schon geschrieben hat, ohne dass Du die Grundlagen von Python lernst und damit auch verstehen kannst, was Du da eintippst, wirst Du nicht weiter kommen.

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Mittwoch 11. Oktober 2017, 08:47
von kbr
@dilbert: Du verwendest Python 3, da klappt einiges von der Python 2 Syntax nicht mehr. Du müsstest also schreiben:

Code: Alles auswählen

>>> print((feature['tags']['name'], feature['id']) for feature in response['elements'])
Ohne Kenntnis von Python hilft Dir das allerdings nur bis zur nächsten Codezeile. Programmieren kann Spaß machen, insbesondere mit Python. Es ist aber keine Bastelarbeit und funktioniert nur mit copy & paste definitiv nicht.

Re: overpass-api-python-wrapper installieren - u. mit ihm arbeiten

Verfasst: Mittwoch 11. Oktober 2017, 10:36
von dilbert
hallo Sirius hallo KbR

vielen Dank für Eure Antworten - für die Tipps zum Thema u. für die freundliche Einladung zu Python ;)
wie kbr schon geschrieben hat, ohne dass Du die Grundlagen von Python lernst und damit auch verstehen kannst, was Du da eintippst, wirst Du nicht weiter kommen.
Sehr gerne - ich nütz das praktische Thema um daran auch zu lernen.

Werde das heute Abend ausprobieren -

VG Dilbert