This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author giumas
Recipients giumas, paul.moore, steve.dower, tim.golden, zach.ware
Date 2016-02-21.14:39:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1456065583.71.0.292979306373.issue26400@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-02-21 14:39:43giumassetrecipients: + giumas, paul.moore, tim.golden, zach.ware, steve.dower
2016-02-21 14:39:43giumassetmessageid: <1456065583.71.0.292979306373.issue26400@psf.upfronthosting.co.za>
2016-02-21 14:39:43giumaslinkissue26400 messages
2016-02-21 14:39:43giumascreate