Erzwingen, dass Windows 7 ausführbare Python-Skriptdateien (insbesondere ein IPython-Pipe) nicht in einem neuen Popup-Cmd-Fenster öffnet

989
alonisser

Bedeutet, dass wenn ich von der Kommandozeile renne, etwas wie:

Ipython 

oder

pip install somelib 

Windows führt sie in einem neuen Cmd-Fenster und nicht im aktuellen Fenster aus. Wenn eine Fehlermeldung angezeigt wird, kann ich sie normalerweise nicht sehen, da das Fenster geschlossen wird.

Ich kann (die meisten) Python-Skripts inline ausführen, wenn ich die lange Version verwende:

python pip-script.py install somelib 

Dies ist jedoch sehr umständlich und nicht jedes Python-Tool exe verfügt über eine -script.py-Version.

wie kann das gelöst werden? Danke für die Hilfe

2

3 Antworten auf die Frage

2
user2097818

I have Windows 7 Home Premium and I do not experience this same behavior anymore, although some of them did cause some headaches. If you can get a distribution of python that has compiled .exe wrappers for the power-tools, I would try to do this (I never call pip.py, I have a pip.exe that executes in cmd.exe right out of the box).

Most notably, take care when executing .bat files that wrap up your scripts. BAT files will do what you described if not set up properly. Instead of using BAT files, I prefer to make links. Then you can set the target manually and other execution characteristics.

If you are having trouble with a particular command, you will probably need to track down the actual target of your command, and see how it is being run. Some pythons wrap up modules in .BATs, and they can behave wrong if you don't realize this.

One last thing, running commands from the Run-Prompt IS NOT THE SAME as running from cmd.exe. I don't know the exact differences, I just know that it generally does not work.

Edit:: If you are in cmd.exe, and you type 'python', what happens?

Dies führte in die richtige Richtung, daher die Aufwertung (auch eine Aufwertung für einen neuen Benutzer, der versucht, der Community zu helfen). aber hier gibt es keine "bat" -Dateien, zumindest für mich keine Sichtbarkeit alonisser vor 11 Jahren 0
0
Karan

Run the commands from an elevated command prompt (Start / Type "cmd" / right-click cmd.exe / Run as administrator). If they still open a new window, it's likely that's what they're hard coded to do.

Das funktioniert nicht, aber ich bin mir ziemlich sicher, dass dies nicht hart codiert ist, da es in win xp nicht so war alonisser vor 11 Jahren 0
0
alonisser

Gelöst von selbst. Es scheint, dass sich die pip.exestandardmäßig installierte Datei (in python27\scripts) aus irgendeinem Grund so verhält, auch soll sie nur ein pip-script.pyWrapper sein (denke ich). Aber das Kopieren einer pip.exeDatei aus einem Virtualenv-Scripts-Ordner in den Haupt-Python-Scripts-Ordner funktioniert einfach .. und zumindest kann ich dies überprüfen (`pip --version). Es bezieht sich auf die Standardinstallation von Python und nicht auf die in der Virtualenv. bringt mich zum Lächeln