Message260612
On Windows, I am getting a `SyntaxError` when I try to input commands after having launched a Python 2.7.x interpreter with `subprocess.call`.
This is a minimal example:
import os
import subprocess
def python_env_path(python_path):
env = os.environ.copy()
python_scripts = os.path.join(python_path, "Scripts")
python_bin = os.path.join(python_path, "Library", "bin")
path_env = "%s;%s;%s;" % (python_path, python_scripts, python_bin)
env['PATH'] = path_env.encode()
return env
def open_python_prompt(python_path):
env = python_env_path(python_path)
prc = subprocess.call(["start", "python"],
shell=True, cwd=python_path, env=env)
if prc != 0:
print("Unable to open a Python prompt")
return False
return True
open_python_prompt("C:\Py27x64")
When I try to write whatever simple command for the interpreter I get:
>>> a = 0
File "<stdin>", line 1
a = 0
^
SyntaxError: invalid syntax
I did not find SO questions that solve my issue.
The same code works fine with Python 3.x.
The same Python installation works fine if I open a shell and call the interpreter using a batch file. |
|
Date |
User |
Action |
Args |
2016-02-21 14:39:43 | giumas | set | recipients:
+ giumas, paul.moore, tim.golden, zach.ware, steve.dower |
2016-02-21 14:39:43 | giumas | set | messageid: <1456065583.71.0.292979306373.issue26400@psf.upfronthosting.co.za> |
2016-02-21 14:39:43 | giumas | link | issue26400 messages |
2016-02-21 14:39:43 | giumas | create | |
|