如何正确构建别名?

2 python unix subprocess

python3.3在我的脑中添加了一个新的别名,.bash_profile以便轻松启动pyzopython3.3版本.

我可以在终端中使用这个别名没有任何问题,但是当我使用类似的东西时subprocess.check_call(args = ["python3.3", onePyFile]),我有以下错误.

Traceback (most recent call last):
  ...
  File "/Library/Frameworks/pyzo2013b/lib/python3.3/subprocess.py", line 540, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/Library/Frameworks/pyzo2013b/lib/python3.3/subprocess.py", line 521, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/Library/Frameworks/pyzo2013b/lib/python3.3/subprocess.py", line 818, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/pyzo2013b/lib/python3.3/subprocess.py", line 1416, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'python3.3'
Run Code Online (Sandbox Code Playgroud)

我想我的别名到处都看不到.那么我该如何解决我的问题呢?构建自己的别名的好方法是什么?

如果我尝试subprocess.check_call(args = ["python3.3", onePyFile], shell = True),我有以下错误.

onePyFile.py: python3.3: command not found
Traceback (most recent call last):
  File "mainFile.py", line 72, in <module>
    shell = True
  File "/Library/Frameworks/pyzo2013b/lib/python3.3/subprocess.py", line 545, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['python3.3', 'onePyFile.py']' returned non-zero exit status 127
Run Code Online (Sandbox Code Playgroud)

如果我只使用subprocess.check_call(args = ["python3.3", onePyFile])第一行的onePyFile位置#! /usr/bin/env python3.3,我有以下错误.

env: python3.3: No such file or directory
Traceback (most recent call last):
  ...
Run Code Online (Sandbox Code Playgroud)

我认为我的问题更多的是关于符号链接而不是Python调用.但我不知道出了什么问题.实际上,这是我第一次与别名建立个人符号链接.

Leo*_*o.Z 5

尝试 subprocess.check_call(args = ["python3.3", onePyFile] , shell=True, env={'ENV':path_of_bash_profile})

如果shell为True,则将通过shell执行指定的命令.如果您主要使用Python来提供它在大多数系统shell上提供的增强控制流,并且仍然希望方便地访问其他shell功能,例如shell管道,文件名通配符,环境变量扩展以及将〜扩展到用户家中,这将非常有用.目录.但请注意,Python本身提供了许多类似shell的功能的实现(特别是glob,fnmatch,os.walk(),os.path.expandvars(),os.path.expanduser()和shutil).