AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Delphi-PRAXiS - Lounge Betriebssysteme Wie starte ich ein Python-Skript?
Thema durchsuchen
Ansicht
Themen-Optionen

Wie starte ich ein Python-Skript?

Ein Thema von Der schöne Günther · begonnen am 21. Okt 2015 · letzter Beitrag vom 21. Okt 2015
Antwort Antwort
Der schöne Günther

Registriert seit: 6. Mär 2013
6.196 Beiträge
 
Delphi 10 Seattle Enterprise
 
#1

AW: Wie starte ich ein Python-Skript?

  Alt 21. Okt 2015, 16:54
Hallo-

Vielen Dank für die Hilfe. Habe Python 3 runtergeworfen und Python 2.7 installiert.

Mit "Pip" habe ich es auch versucht zu installieren: "pip instal poxls" meint alles sei in Ordnung, bei Ausführung des Skripts bekomme ich immer Folgendes:

Code:
Y:\>python y:\po_to_xls.py
Traceback (most recent call last):
  File "y:\po_to_xls.py", line 7, in <module>
    from . import ColumnHeaders
ValueError: Attempted relative import in non-package
Ich habe das Gefühl, irgendwas mache ich noch beim Ausführen falsch.


Eine Internet-Suche nach "Attempted relative import in non-package" ergibt nur Dinge bei denen ich kein Wort verstehe. Ein guter Treffer ist aber dabei:

Zitat:
[...]
When you attempt to run module "a" as a script: $ python test_relative_import/a.py
Traceback (most recent call last):
File "test_relative_import/a.py", line 1, in
from . import b
ValueError: Attempted relative import in non-package
$

You cannot run a python file as a script with relative import. You need to run it as a module. This works: $ python -m test_relative_import.a
hello

The reason is that if you run "a.py" as a script, its module name would be "__main__". That name cannot tell where the module is, so python cannot figure out where that "." in "from . import" is. One subtle thing is that if you run "a.py" as a module but in the same directory as "a.py", it does not work either. [...]
Gehe ich nun in src-Verzeichnis und gebe ein
Code:
python -m poxls.po_to_xls
bekomme ich:
Code:
Usage: po_to_xls.py [OPTIONS] CATALOG

Error: Missing argument "catalogs".
Hurra, es scheint zu funktionieren (fürs Erste)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:02 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz