我刚安装了一个基本的gentoo阶段3,当我尝试调用time.time()时,出现以下错误:
sbx /#python import时间 Python 2.7.1(r271:86832,2011年5月22日,14:53:09) linux2上的[GCC 4.4.5] 请input“帮助”,“版权”,“信用”或“许可证”以获取更多信息。 >>>import时间 >>> time.time() 回溯(最近一次通话最后): 文件“”,第1行, IOError:[Errno 0]错误
我发现这是因为当我尝试运行emerge时,我得到:
sbx /#出现 回溯(最近一次通话最后): 文件“/ usr / bin / emerge”,第32行, 从_emerge.main导入emerge_main 文件“/usr/lib/portage/pym/_emerge/main.py”,第6行, 导入日志 文件“/usr/lib/python2.7/logging/__init__.py”,第94行,in _startTime = time.time() IOError:[Errno 11]资源暂时不可用
这是一个自定义的内核,我只是确保我在RTC支持编译,但仍然没有运气。 任何想法,为什么发生这种情况?
你的自定义内核之前工作吗? 启动一个救援CD,chroot到你的gentoo环境,并运行你的脚本。 如果有效,那就是你的内核。 这是关于我可以具体。
可能这是你的问题?
http://bugs.gentoo.org/show_bug.cgi?id=330937
编辑 C测试代码
#include <stdio.h> #include <sys/time.h> typedef struct timeval _PyTime_timeval; void _PyTime_gettimeofday(_PyTime_timeval *tp) { /* There are three ways to get the time: (1) gettimeofday() -- resolution in microseconds (2) ftime() -- resolution in milliseconds (3) time() -- resolution in seconds In all cases the return value in a timeval struct. Since on some systems (eg SCO ODT 3.0) gettimeofday() may fail, so we fall back on ftime() or time(). Note: clock resolution does not imply clock accuracy! */ #ifdef HAVE_GETTIMEOFDAY #ifdef GETTIMEOFDAY_NO_TZ if (gettimeofday(tp) == 0) return; #else /* !GETTIMEOFDAY_NO_TZ */ if (gettimeofday(tp, (struct timezone *)NULL) == 0) return; #endif /* !GETTIMEOFDAY_NO_TZ */ #endif /* !HAVE_GETTIMEOFDAY */ #if defined(HAVE_FTIME) { struct timeb t; ftime(&t); tp->tv_sec = t.time; tp->tv_usec = t.millitm * 1000; } #else /* !HAVE_FTIME */ tp->tv_sec = time(NULL); tp->tv_usec = 0; #endif /* !HAVE_FTIME */ return; } int main(int argc, char** argv) { _PyTime_timeval time; _PyTime_gettimeofday(&time); double tval = 0; tval = (double) time.tv_sec + time.tv_usec * 0.000001; printf("Time value was %f\n", tval); }
如果我用gcc -DHAVE_GETTIMEOFDAY testtime.c
编译这个,我得到一个工作时间输出,这就是python正在引入的内容。
也许是在一个嵌入式平台上,你需要说服python你的c库提供的时间函数是错误的,或者是在kernel / C lib bits