Python Setup.py Build_Ext --inplace
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26574533/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python Setup.py Build_Ext --inplace
提问by G01
I am building a Cython program (called for ex. testpackage) using the command:
我正在使用以下命令构建一个 Cython 程序(例如 testpackage):
python setup.py build_ext --inplace
In a folder like /home/USER/Documents/testpackage/. The build runs successfully but when I cd into another folder, I can no longer use the module testpackage. Is there another command I can run instead of --inplaceso that I can import testpackagein Python in any folder? I looked at the anaconda/lib/python2.7/site-packages/folder and do not see any reference to testpackageanywhere. Is this standard for Cython builds?
在像/home/USER/Documents/testpackage/. 构建成功运行,但是当我 cd 进入另一个文件夹时,我无法再使用模块testpackage. 是否有另一个我可以运行的命令,而不是--inplace我可以import testpackage在 Python 中的任何文件夹中运行的命令?我查看了anaconda/lib/python2.7/site-packages/文件夹,没有看到任何对testpackage任何地方的引用。这是 Cython 构建的标准吗?
NOTE: I am doing this through a .sh file using conda build testpackageso the command python setup.py build_ext --inplaceis actually in the shell file.
注意:我是通过 .sh 文件执行此操作的,conda build testpackage因此命令python setup.py build_ext --inplace实际上位于 shell 文件中。
Thank you for your help.
感谢您的帮助。
回答by ProProcrastinatrix
The --inplace option creates the shared object file (with .so suffix) in the current directory. To use this module from python this file must be in the python path (sys.path).
--inplace 选项在当前目录中创建共享对象文件(带有 .so 后缀)。要从 python 使用这个模块,这个文件必须在 python 路径 (sys.path) 中。
To install to the system python folder run
安装到系统 python 文件夹运行
python setup.py build_ext
sudo python setup.py install
If you don't have admin rights, you can also install locally using
如果您没有管理员权限,您也可以使用本地安装
python setup.py build_ext
python setup.py install --user

