我试图通过命令行进程从C#运行Python。
System.Diagnostics.Process proc = new System.Diagnostics.Process {
StartInfo = new System.Diagnostics.ProcessStartInfo {
FileName = "/Users/username/.pyenv/shims/python",
Arguments = cmd+" "+args,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true
}
};
我使用
which
:
username$ which python
/Users/username/.pyenv/shims/python
但是,运行
python --version
从终端,然后再次通过C#过程,产生不同的结果:
username$ python -V
Python 2.7.11
和C#:
Python 2.7.10
我理解基本问题——它调用的是Python的另一个版本,可能是来自苹果的基本版本。但我不明白的是
为什么?
,因为据我所知,我告诉它直接从pyenv调用python。有没有办法让C#使用我在终端上使用的同一个python可执行文件?