Python代理newrelic安装
Python agent newrelic installation
我正在尝试在我的网络应用程序上安装 python newrelic 代理,但我做不到。我正在使用名为 code.py 的文件来启动我的应用程序。
我在乞讨中添加:
import newrelic.agent
newrelic.agent.initialize('newrelic.ini')
我也试过了:
import newrelic.agent
newrelic.agent.initialize('/root/web/newrelic.ini')
但我收到一些错误,例如
Traceback (most recent call last):
File "code.py", line 2, in <module>
import newrelic.agent
File "/usr/local/lib/python2.7/dist-packages/newrelic- 2.44.0.36/newrelic/agent.py", line 1, in <module>
from .config import initialize, extra_settings
File "/usr/local/lib/python2.7/dist-packages/newrelic-2.44.0.36/newrelic/config.py", line 34, in <module>
import newrelic.console
File "/usr/local/lib/python2.7/dist-packages/newrelic-2.44.0.36/newrelic/console.py", line 5, in <module>
import code
File "/root/web/code.py", line 3, in <module>
newrelic.agent.initialize('newrelic.ini')
AttributeError: 'module' object has no attribute 'agent'
有人可以帮忙吗??谢谢
您需要将脚本重命名为 code.py
以外的名称。 (并且,还要删除 code.pyc
。)问题是您的脚本名称与 standard Python module called code 冲突,因此当代理尝试 import code
时,它最终会导入您的脚本,而不是标准模块.
有关详细信息,请参阅 "name shadowing trap" 的描述:http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html#the-name-shadowing-trap
我正在尝试在我的网络应用程序上安装 python newrelic 代理,但我做不到。我正在使用名为 code.py 的文件来启动我的应用程序。 我在乞讨中添加:
import newrelic.agent
newrelic.agent.initialize('newrelic.ini')
我也试过了:
import newrelic.agent
newrelic.agent.initialize('/root/web/newrelic.ini')
但我收到一些错误,例如
Traceback (most recent call last):
File "code.py", line 2, in <module>
import newrelic.agent
File "/usr/local/lib/python2.7/dist-packages/newrelic- 2.44.0.36/newrelic/agent.py", line 1, in <module>
from .config import initialize, extra_settings
File "/usr/local/lib/python2.7/dist-packages/newrelic-2.44.0.36/newrelic/config.py", line 34, in <module>
import newrelic.console
File "/usr/local/lib/python2.7/dist-packages/newrelic-2.44.0.36/newrelic/console.py", line 5, in <module>
import code
File "/root/web/code.py", line 3, in <module>
newrelic.agent.initialize('newrelic.ini')
AttributeError: 'module' object has no attribute 'agent'
有人可以帮忙吗??谢谢
您需要将脚本重命名为 code.py
以外的名称。 (并且,还要删除 code.pyc
。)问题是您的脚本名称与 standard Python module called code 冲突,因此当代理尝试 import code
时,它最终会导入您的脚本,而不是标准模块.
有关详细信息,请参阅 "name shadowing trap" 的描述:http://python-notes.curiousefficiency.org/en/latest/python_concepts/import_traps.html#the-name-shadowing-trap