创建程序的符号链接
假设我在 ~/programming/ass1 中,可执行文件在 ~/programming/ass1/seattle/seattle_repy/repy.py 中。
我尝试创建一个像这样的符号链接
ln -s seattle/seattle_repy/repy.py repy
能够键入,
python repy restrictions.test example.1.1.repy
,以便
python seattle/seattle_repy/repy.py restrictions.test example.1.1.repy
但它不起作用(我得到“python:无法打开文件'/home/philipp/Desktop/Uni/NTM/UE/Uebungsblatt 3/safe_check .py':[Errno 2]没有这样的文件或目录”)。 所以repy.py找不到safe_check.py。
这有可能吗?
干杯, 菲利普
Suppose I am in ~/programming/ass1 and the executable is in ~/programming/ass1/seattle/seattle_repy/repy.py.
I tried to create a symlink like so
ln -s seattle/seattle_repy/repy.py repy
to be able to type
python repy restrictions.test example.1.1.repy
instead of
python seattle/seattle_repy/repy.py restrictions.test example.1.1.repy
But it didn't work (I get "python: can't open file '/home/philipp/Desktop/Uni/NTM/UE/Uebungsblatt 3/safe_check.py': [Errno 2] No such file or directory").
So repy.py can't find safe_check.py.
Is this possible at all?
Cheers,
Philipp
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要 frob sys.path 来添加包含模块的路径,但制作一个调用 exec python ~/programming/ass1/seattle/seattle_repy/ 的 shell 脚本可能更容易复制.py。
You'll need to frob
sys.path
to add the path containing the modules, but it's probably easier to make a shell script that callsexec python ~/programming/ass1/seattle/seattle_repy/repy.py
.感谢伊格纳西奥和马克的建议。
我用 ~/programming/ass1 中的以下 bash 脚本解决了这个问题
为了最终得到我想要的东西,我将其复制到 /usr/bin 并创建了一个符号链接:
所以现在我只能说
repy requests.test 示例。 2.1.repy
就可以了。Thanks for the tips Ignacio and Mark.
I solved it with the following bash script in ~/programming/ass1
To finally get what I want I copied it to /usr/bin and created a symlink to it:
So now I can just say
repy restrictions.test example.2.1.repy
and it'll work.