简体   繁体   English

使用Jython运行python脚本时,“sys-package-mgr *:无法创建包缓存目录”

[英]“sys-package-mgr*: can't create package cache dir” when run python script with Jython

I want to run Python script with Jython. 我想用Jython运行Python脚本。

the result show correctly, but at the same time there is an warning message, "sys-package-mgr*: can't create package cache dir" 结果显示正确,但同时有一条警告消息,“sys-package-mgr *:无法创建包缓存目录”

How could I solve this problem? 我怎么能解决这个问题?

thanks in advance~~~ 提前谢谢~~~

1) By changing permissions to allow writing to the directory in the error message. 1)通过更改权限以允许写入错误消息中的目录。

2) By setting python.cachedir.skip = true 2)通过设置python.cachedir.skip = true

You can read this: 你可以读到这个:

http://www.jython.org/jythonbook/en/1.0/ModulesPackages.html#module-search-path-compilation-and-loading http://www.jython.org/jythonbook/en/1.0/ModulesPackages.html#module-search-path-compilation-and-loading

for further insights. 进一步的见解。

You can change the location of the cache directory to a place that you have read & write access to by setting the "python.cachedir" option when starting jython, eg: 您可以通过在启动jython时设置“python.cachedir”选项,将缓存目录的位置更改为您具有读写访问权限的位置,例如:

jython -Dpython.cachedir=*your cachedir directory here*

or: 要么:

java -jar my_standalone_jython.jar -Dpython.cachedir=*your cachedir directory here*

You can read about the python.cachedir option here: http://www.jython.org/archive/21/docs/registry.html 你可以在这里阅读python.cachedir选项: http ://www.jython.org/archive/21/docs/registry.html

Making directories world writable admittedly makes the problem "go away", however, it introduces a huge security hole. 让目录成为可写的公认使问题“消失”,然而,它引入了一个巨大的安全漏洞。 Anyone could introduce code to the now world writable directory that would be executed in the users' jpython environment. 任何人都可以将代码引入到将在用户的jpython环境中执行的现在可写的目录。

Setting the cachedir to skip would presumably result in a performance drop (why implement a caching scheme other than to improve performace). 将cachedir设置为skip可能会导致性能下降(为什么实现缓存方案而不是提高性能)。

Instead I did the following: 相反,我做了以下事情:

I created a new group (in my case eclipse, but it could have been jpython). 我创建了一个新组(在我的例子中是eclipse,但它可能是jpython)。 I added the users of jpython to that group. 我将jpython的用户添加到该组。

$ sudo groupadd eclipse

I then changed the group of my eclipse plugins folder and its children to 'eclipse'. 然后我将我的eclipse插件文件夹及其子组改为'eclipse'。

/opt/eclipse/plugins $ sudo chgrp -R eclipse *

Then I changed the group permissions as follows 然后我更改了组权限,如下所示

/opt/eclipse/plugins $ sudo chmod -R g+w *
/opt/eclipse/plugins $ find * -type d -print | sudo xargs chmod g+s

This added group writable, and set the S_GID bit on all directories recursively. 这个添加的组可写,并递归地在所有目录上设置S_GID位。 This last bit causes new directories created to have the same group id as their parent. 最后一位导致创建的新目录与其父目录具有相同的组ID。

The final touch was change the umask for the eclipse users set to 007. 最后一步是将eclipse用户设置为007的umask更改。

$ sudo vi /etc/login.def

change UMASK to 007 (from 022). 将UMASK更改为007(从022开始)。 UMASK=007 UMASK = 007

到目前为止我发现的最简单的修复方法是:

$ sudo chmod -R 777 /opt/jython/cachedir

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM