为了账号安全,请及时绑定邮箱和手机立即绑定

python NameError:全局名称'__file__'未定义

python NameError:全局名称'__file__'未定义

胡子哥哥 2021-03-25 14:12:25
当我在python 2.7中运行此代码时,出现此错误:Traceback (most recent call last):File "C:\Python26\Lib\site-packages\pyutilib.subprocess-3.5.4\setup.py", line 30, in <module>    long_description = read('README.txt'),  File "C:\Python26\Lib\site-packages\pyutilib.subprocess-3.5.4\setup.py", line 19, in read    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()NameError: global name '__file__' is not defined代码是:import osfrom setuptools import setupdef read(*rnames):    return open(os.path.join(os.path.dirname(__file__), *rnames)).read()setup(name="pyutilib.subprocess",    version='3.5.4',    maintainer='William E. Hart',    maintainer_email='wehart@sandia.gov',    url = 'https://software.sandia.gov/svn/public/pyutilib/pyutilib.subprocess',    license = 'BSD',    platforms = ["any"],    description = 'PyUtilib utilites for managing subprocesses.',    long_description = read('README.txt'),    classifiers = [        'Development Status :: 4 - Beta',        'Intended Audience :: End Users/Desktop',        'License :: OSI Approved :: BSD License',        'Natural Language :: English',        'Operating System :: Microsoft :: Windows',        'Operating System :: Unix',        'Programming Language :: Python',        'Programming Language :: Unix Shell',        'Topic :: Scientific/Engineering :: Mathematics',        'Topic :: Software Development :: Libraries :: Python Modules'],      packages=['pyutilib', 'pyutilib.subprocess', 'pyutilib.subprocess.tests'],      keywords=['utility'],      namespace_packages=['pyutilib'],      install_requires=['pyutilib.common', 'pyutilib.services']      )
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 280 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信