[英]How can I execute a binary file located in the installation directory of my Python package (without sudo)
Let's say I have a Python package structure like that: 假设我有一个像这样的Python包结构:
top-level/
__init__.py
utilities.py
myscript.py
binaryfile
LICENSE.txt
MANIFEST.in
README.rst
setup.cfg
setup.py
When I installed the package it will be located in: 安装软件包时,它将位于:
/usr/local/lib/python2.7/dist-packages/mypackage/
and the path of binary file will be: 二进制文件的路径为:
/usr/local/lib/python2.7/dist-packages/mypackage/binaryfile
My question is: How can I execute this binary file that located under /usr/local/...
without root privileges (without sudo) from a script located in my package. 我的问题是:如何执行位于
/usr/local/...
下的二进制文件, 而没有来自我程序包中脚本的root特权 (无sudo)。
I'm using my package as a console script so instead of using: 我使用我的软件包作为控制台脚本,所以没有使用:
sudo mypackage
to run my package, I wanna use only: 运行我的包,我只想使用:
mypackage
You want to give execute permission to normal users, so running 您想将执行权限授予普通用户,因此运行
sudo chmod +x /usr/local/lib/python2.7/dist-packages/mypackage/binaryfile
once should make it possible for normal users to execute it. 一次应该使普通用户可以执行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.