简体   繁体   English

以root身份运行Enthought Canopy Python无法导入熊猫

[英]Running Enthought Canopy Python as root cannot import pandas

I want to access files and directories which may require root permission from a command line call to a python script using Enthought Canopy Python. 我想访问文件和目录,这些文件和目录可能需要使用Enthought Canopy Python从命令行调用到python脚本的root权限。 However running python as root gives me the system distributed python. 但是以root身份运行python给了我系统分布式python。

$ python

Enthought Canopy Python 2.7.6 | 64-bit | (default, Sep 15 2014, 17:36:10) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

$ sudo python

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

Same results using default bash terminal (Ubuntu Linux 14.04) and using the canopy command line (Canopy 1.5.2). 使用默认bash终端(Ubuntu Linux 14.04)和使用冠层命令行(Canopy 1.5.2),结果相同。

I reinstalled Canopy as root (ie re-ran the shell script as root) and the same problem still occurs. 我以root身份重新安装了Canopy(即以root身份重新运行了shell脚本),仍然出现相同的问题。

Is there an easy way to run Canopy as root? 有没有一种简单的方法可以以root身份运行Canopy? I am not trying to distribute it to a number of users on a system just run a python script on files that need root permissions. 我不是试图将其分发给系统上的许多用户,而只是在需要root权限的文件上运行python脚本。

It sounds like sudo is not using your current PATH settings to locate the executable to run. 听起来sudo没有使用您当前的PATH设置来定位要运行的可执行文件。 IIRC this is a configuration option for sudo, whether to use a limited default PATH or not. IIRC这是sudo的配置选项,无论是否使用有限的默认PATH。

An easy way to work around this is to specify the full path to the python excutable that you want to execute. 解决此问题的一种简单方法是指定要执行的python可执行文件的完整路径。 For example, if you've activated a Canopy virtual environment, then you can do it like this: 例如,如果您已激活Canopy虚拟环境,则可以这样进行:

$ sudo $VIRTUAL_ENV/bin/python

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

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