python NameError: global name '__file__' is not defined

前端 未结 12 860
误落风尘
误落风尘 2020-12-02 08:08

When I run this code in python 2.7, I get this error:

Traceback (most recent call last):
File \"C:\\Python26\\Lib\\site-packages\\pyutilib.subprocess-3.5.4\\         


        
12条回答
  •  悲哀的现实
    2020-12-02 08:23

    I had the same problem in Jupyter notebook. While I used 'os.path.split(os.path.realpath(file))' , the notebook was throwing an error.

    I thus used 'file'. It worked perfectly.

提交回复
热议问题