Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python模块属性是否在Python shell中定义?_Python_Paraview_Python Os - Fatal编程技术网

Python模块属性是否在Python shell中定义?

Python模块属性是否在Python shell中定义?,python,paraview,python-os,Python,Paraview,Python Os,如果我在一个Python脚本中使用了_; file __;说明符,该脚本将在Paraview的内置Python shell中运行,那么它应该能够正确地解释它?或者任何Python REPL。但是,如果我直接在Python shell中使用_; file _;属性,那么它将无法解释它。这种想法正确吗 当我试图在shell中运行一个脚本来恢复文件路径时,我试图在Paraview中回溯错误。这是我正在尝试运行的脚本 导入操作系统 dir=os.path.dirname(os.path.realpath

如果我在一个Python脚本中使用了_; file __;说明符,该脚本将在Paraview的内置Python shell中运行,那么它应该能够正确地解释它?或者任何Python REPL。但是,如果我直接在Python shell中使用_; file _;属性,那么它将无法解释它。这种想法正确吗

当我试图在shell中运行一个脚本来恢复文件路径时,我试图在Paraview中回溯错误。这是我正在尝试运行的脚本

导入操作系统
dir=os.path.dirname(os.path.realpath(_文件__))
打印(目录)

希望这不是含糊不清的任何帮助将是感激的,我已经被困在这一段时间了

在从此处下载的ParaView 5.8-RC1中运行良好:

此功能是最近才添加的,您可以在此处看到:


这仅仅是因为ParaView开发人员确保它工作正常。此变量在此类环境中不会自动可用。

您可以发布错误回溯吗?您是从模块还是从REPL运行上述代码?我是直接从Paraview的Python REPL运行它。问题是,我没有收到任何类型的错误消息,只是在REPL中打印时得到了一个不正确的文件路径。这是我之前的一篇文章,没有人回应,或多或少总结了我的问题。谢谢你的回复。我仍然有相同的问题,请参阅我对您的解决方案的评论。谢谢你的帮助@阿米蒂帕蒂