Python3.8 在 PATH 环境变量中找不到命令 (Ubuntu)
Python3.8 cannot find command in the PATH env var (Ubuntu)
当 运行 使用 python38 的 python 脚本时,它给出:
FileNotFoundError: [Errno 2] No such file or directory: 'riscv32-unknown-elf-objdump'
'riscv32-unknown-elf-objdump' 在我的 shell 命令行的 $PATH 上,也在 python 脚本本身打印的 sys.path 上。
如果我切换到 python3,那么这个错误就会消失。
python 行产生错误:
result = subprocess.run(["riscv32-unknown-elf-objdump", "-S", "-M", "numeric", exe_file], stdout=PIPE, stderr=PIPE, encoding="ASCII")
有什么提示吗?
编辑:版本在脚本头中定义,例如
#!/usr/bin/env python38
我发现解决这个问题的方法是在 subprocess:
的调用中添加 shell=True
result = subprocess.run(["riscv32-unknown-elf-objdump", "-S", "-M", "numeric", exe_file], stdout=PIPE, stderr=PIPE, encoding="ASCII",shell=True)
仍然不知道为什么 python3.8 而不是早期版本需要这样做。
当 运行 使用 python38 的 python 脚本时,它给出:
FileNotFoundError: [Errno 2] No such file or directory: 'riscv32-unknown-elf-objdump'
'riscv32-unknown-elf-objdump' 在我的 shell 命令行的 $PATH 上,也在 python 脚本本身打印的 sys.path 上。
如果我切换到 python3,那么这个错误就会消失。 python 行产生错误:
result = subprocess.run(["riscv32-unknown-elf-objdump", "-S", "-M", "numeric", exe_file], stdout=PIPE, stderr=PIPE, encoding="ASCII")
有什么提示吗?
编辑:版本在脚本头中定义,例如
#!/usr/bin/env python38
我发现解决这个问题的方法是在 subprocess:
的调用中添加shell=True
result = subprocess.run(["riscv32-unknown-elf-objdump", "-S", "-M", "numeric", exe_file], stdout=PIPE, stderr=PIPE, encoding="ASCII",shell=True)
仍然不知道为什么 python3.8 而不是早期版本需要这样做。