Trace files/modules loaded when launching python

好久不见. 提交于 2020-01-07 05:23:14

问题


I am using Paraview 4.0.1 under Ubuntu 14.04 LTS. But I guess the answer to this question does not necessarily requires knowledge specific to Paraview python.

When I load a python prompt at the command line everything "works well":

$ pvpython 
Python 2.7.6 (default, Oct 26 2016, 20:33:43) 
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from paraview.simple import *
paraview version 4.0.1
>>> 

But when I load the python shell within the GUI, from paraview.simple import * fails, either when automatically (at startup) or explicitly imported:

Python 2.7.6 (default, Oct 26 2016, 20:33:43) 
[GCC 4.8.4] on linux2
from paraview.simple import *
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/paraview/simple.py", line 41, in <module>
    import servermanager
  File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 3157, in <module>
    __initialize()
  File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 3148, in __initialize
    c = Connection(iter.GetCurrentSessionId(), iter.GetCurrentSession())
  File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 1935, in __init__
    _createModules(self.Modules)
  File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 2567, in _createModules
    m.filters = createModule('filters')
  File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 2629, in createModule
    if (prop.GetInformationOnly() and propName != "TimestepValues" ) \
AttributeError: 'NoneType' object has no attribute 'GetInformationOnly'
>>> from paraview.simple import *
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/paraview/servermanager.py", line 2190, in find_module
    if vtkPVPythonModule.HasModule(fullname):
AttributeError: 'NoneType' object has no attribute 'HasModule'
>>> 

How can I trace the different sequence of steps taken by each mode of loading a python shell, so as to identify the source of error?

In addition to this manifestation, I found two other differences:

  1. In the command prompt, from paraview.simple import * is not executed automatically, while in the GUI it is. Where is this set?

  2. In the command prompt, having set PYTHONSTARTUP=${HOME}/.pythonrc, which sets import readline, rlcompleter (actually, within a try-except construct), allows for tab completion. In the GUI, .pythonrc is not read. Why is this? How can I tell the filename which would be read upon startup if it exists?


回答1:


I have found one option which gives some information, I do not know if it is the only/best one.

Setting

$ export PYTHONVERBOSE=2

(or a different integer for verbosity level [1]) gives a lot of info. Still, I couldn't find the source of error...



来源:https://stackoverflow.com/questions/47457230/trace-files-modules-loaded-when-launching-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!