简体   繁体   中英

import error in eclipse, running an app as root

Im developing an installer for a GNU/Linux distribution in Python using Eclipse+PyDev. For some tasks on it there is needed that the program runs with root priviledges, but I run Eclipse as a common user.

I had searched a lot of stuff on the Internet about how to run an app as root without having to run Eclipse with priviledges, but no a single clue of how to accomplish this in a "nice way". So I tried with the "gksu2" python module, with has the gksu2.sudo() functions in the same way as gksu in bash.

I created a new module, imported gksu2 and executed the main.py module of the app, but I got a "ImportError: No module named ui.regular_ui.wizard". It runs ok without gksu2 in eclipse, but it doesn't if I use it. I thought it was an environment variables problem, but the sys.path is ok.

The same error happens if I run the app from a terminal, outside of Eclipse. What do you think?

It seems like your PYTHONPATH is different outside/inside Eclipse. Try just removing the Python interpreter and adding it again to gather new paths -- if that's not enough, do: import sys;print('\\n'.join(sorted(sys.path))) outside/inside Eclipse to know what's different and fix your paths inside Eclipse.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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