【问题标题】:How to remove Profiling *.gcda:Cannot open errors with python virtualenv builder?如何删除 Profiling *.gcda:Cannot open errors with python virtualenv builder?
【发布时间】:2018-04-11 05:41:47
【问题描述】:

jenkins 输出中,我收到以下错误。这是一个问题还是可以将其静音?

profiling:/opt/Python-3.6.1/Python/structmember.gcda:Cannot open
profiling:/opt/Python-3.6.1/Python/getcompiler.gcda:Cannot open
profiling:/opt/Python-3.6.1/Objects/odictobject.gcda:Cannot open
profiling:/opt/Python-3.6.1/Objects/enumobject.gcda:Cannot open
profiling:/opt/Python-3.6.1/Objects/descrobject.gcda:Cannot open
profiling:/opt/Python-3.6.1/Objects/cellobject.gcda:Cannot open
profiling:/opt/Python-3.6.1/Objects/bytes_methods.gcda:Cannot open
profiling:/opt/Python-3.6.1/Objects/accu.gcda:Cannot open
profiling:/opt/Python-3.6.1/Parser/myreadline.gcda:Cannot open
profiling:/opt/Python-3.6.1/Parser/parser.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/xxsubtype.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/symtablemodule.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/zipimport.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/stringio.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/textio.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/bufferedio.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/bytesio.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/fileio.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/iobase.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/_iomodule.gcda:Cannot open
profiling:/opt/Python-3.6.1/Modules/_localemodule.gcda:Cannot open

我在debian 8 服务器上从源代码构建了python。

【问题讨论】:

  • virtualenv 是从 Debian 存储库安装的,还是与新构建的 Python 附带的新 pip 一起安装的?

标签: python jenkins


【解决方案1】:

这发生在我做./configure --enable-optimizations 的时候。如果您删除 --enable-optimizations,请重新编译并安装它 - 这些消息不再显示。

总而言之,这是一个新版本 Python 的示例:

wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar xvf Python-3.6.3.tgz
cd Python-3.6.3
./configure
make
sudo make altinstall
python3.6

【讨论】:

  • 对如何解决此问题并保持优化启用有任何想法吗?
  • 很遗憾,我没有关于此事的其他反馈。在这种特殊情况下,解决方案已经足够好了,因此没有动力继续挖掘。也许您可以将 Docker 映像用于您需要的特定版本?
  • 我会尝试 docker,似乎是最好的选择
  • 删除 --enable-optimizations 不是一个好主意,请参阅下面的完整答案。
【解决方案2】:

我通过更改所有者解决了这个问题。我正在使用 ./configure --enable-optimizations 使用 Python 3.6.3 构建 homeassistant。 从我的虚拟环境中,我得到了这些错误,但修复了它们:来自 su / root 帐户

sudo chown -R homeassistant:homeassistant /home/pi/Python-3.6.3

我想也许它可以帮助其他人;) 祝你今天过得愉快!咻!

【讨论】:

    【解决方案3】:

    gcda 文件是gcc profiling 记录,用于查看 CPU 大部分时间都花在了哪些功能上。这会告诉您在优化代码时在哪里可以获得最大收益。

    您可以使用配置选项--enable-optimizations --disable-profiling 保留 Python 代码 opinisations,但不能进行分析。好吧,为我工作。

    正如configure 脚本会告诉您的那样,如果您没有--enable-optimizations,您将失去最佳性能。

    可能获取了gcda 文件,因为您在中途中断了 Python 构建。当您使用--enable-optimizations 运行时,Python 构建将分三个阶段运行

    • 构建代码
    • 运行所有 test 模块以分析代码
    • 重新编译代码以根据分析对其进行优化

    通常认为test 阶段只是检查代码是否正常工作,因为它看起来就是这样做的,但请耐心等待它,它会再次编译,第二次省略分析。

    因此,最好使用--enable-optimizations 和不使用--disable-profiling 进行编译,然后等待,因为这样您应该会得到更好的代码。

    【讨论】:

      猜你喜欢
      • 2012-06-15
      • 1970-01-01
      • 2022-07-19
      • 1970-01-01
      • 2016-04-30
      • 2023-03-17
      • 2019-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多