为什么在我的c++程序中无法识别/usr/local/bin
Why /usr/local/bin is not recognisable in my C++ program?
我的c++代码:
int main(int argc, const char * argv[])
{
system("python test.py");
return 0;
}
我在/usr/local/bin中有一个程序foo
,我可以在Unix控制台中输入foo
,它就启动了。
from subprocess import call
call(["/usr/local/bin/foo"])
这个没有(带有"command not found"错误):
from subprocess import call
call(["foo"])
为什么我的Python脚本,当从c++执行时,不能直接调用程序?
编辑:我用的是Mac OSX。我怀疑这与/usr/local/bin
文件夹没有被c++可执行文件添加或类似的东西有关。
which kallisto
/usr/local/bin/kallisto
cat test.py
from subprocess import call
call(["kallisto"])
python test.py
kallisto 0.43.0
In my C++ run:
Traceback (most recent call last):
File "/Users/tedwong/Sources/QA/test.py", line 2, in <module>
call(["kallisto"])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
感谢@ilent2,他的回答解决了我的问题。我使用IDE来运行c++代码,从来没有意识到我必须告诉IDE我的路径。当我直接在控制台中运行相同的程序时,它工作了。
相关文章:
- 提升 ASIO 无法识别计时器对象
- 从udp接收帧对于人脸识别来说太慢
- 模板类无法识别友元运算符
- std::visit无法识别类型
- 对于MacOS上的G++,如何添加默认的include目录/usr/local/include和默认的库搜索路径/usr
- 无法识别模板功能
- 我有两个类需要在同一 cpp 文件中相互引用,但第一个类无法识别第二个类类型的对象
- 如何在LLVM中dyn_cast以识别StoreInst?
- 从不同的附加依赖项中识别等同命名的函数
- C++出现控制台错误.我无法识别源代码的问题
- VSCode IntelliSense无法识别SDL框架的SDL_image扩展库
- Qt:"Q3DScatter"即使包含在内也无法识别
- /usr/bin/ld: cannot find -lc++
- 使用指针的类识别
- 如何静态识别动态堆分配?
- 为什么C++无法识别我的对象实例化?
- /usr/bin/ld: build-debug/obj/gpsitem.o: 文件无法识别: 文件被截断
- 带有定制 GLFW 二进制 /usr/bin/ld 的 Centos 7: /usr/local/lib/libglfw3.a(init.c.o):".text"部分中无法识别的重定位 (0x2a)
- /usr/bin/ld找不到标头:未识别的文件格式
- 为什么在我的c++程序中无法识别/usr/local/bin