简体   繁体   English

AttributeError: 模块 'pandas' 没有属性 '__version__'

[英]AttributeError: module 'pandas' has no attribute '__version__'

Please note, this is not a duplicate question.请注意,这不是一个重复的问题。 I'm aware of how to find versions of libraries in python.我知道如何在 python 中查找库的版本。 What's caught my goat is the apparent anomaly when the __version__ command is called in two different ways.当以两种不同的方式调用 __version__ 命令时,我的山羊被抓到了明显的异常。

Has anyone faced this before?有没有人遇到过这种情况? When I type the following in IDLE, I get the output which specifies the pandas version.当我在 IDLE 中输入以下内容时,我得到指定熊猫版本的输出。

>>>import pandas as pd
>>>print(pd.__version__)
0.22.0

When I put the same two lines of code into a program, save it and run it, I get the following error:当我将相同的两行代码放入程序,保存并运行时,出现以下错误:

AttributeError: module 'pandas' has no attribute '__version__'

It does not make any sense to me.这对我没有任何意义。 Appreciate any thoughts on this please.请欣赏对此的任何想法。

It sounds like you're not importing the real pandas module when you run your script from a file.当您从文件运行脚本时,这听起来像是您没有导入真正的pandas模块。 When I run your script in a file on my machine it prints the pandas version correctly.当我在机器上的文件中运行您的脚本时,它会正确打印熊猫版本。

Maybe you have a file called pandas.py or a directory called pandas in your current working directory when you run the script?也许您在运行脚本时在当前工作目录中有一个名为pandas.py的文件或一个名为pandas目录? Or maybe there is a pandas.py or a pandas directory in a directory in your PYTHONPATH environment variable?或者,您的 PYTHONPATH 环境变量的目录中可能有pandas.pypandas目录? (Other than the real pandas, that is.) Try running this program and see if the output looks like the proper pandas source file, or something else. (除了真正的 Pandas。)尝试运行这个程序,看看输出是否像正确的 Pandas 源文件或其他东西。

import pandas as pd
print(pd.__file__)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Pandas: AttributeError: 'module' object 没有属性 '__version__' - Pandas: AttributeError: 'module' object has no attribute '__version__' AttributeError: 'module' object 没有属性 '__version__' - AttributeError: 'module' object has no attribute '__version__' AttributeError: 模块 'numexpr' 没有属性 '__version__' - AttributeError: module 'numexpr' has no attribute '__version__' AttributeError:模块“火炬”没有属性“__version__” - AttributeError: module 'torch' has no attribute '__version__' AttributeError:模块“numpy”没有属性“__version__” - AttributeError: module 'numpy' has no attribute '__version__' AttributeError: 模块 'tensorflow' 没有属性 '__version__' - AttributeError: module 'tensorflow' has no attribute '__version__' AttributeError: 模块 'keras' 没有属性 '__version__' - AttributeError: module 'keras' has no attribute '__version__' 追溯属性错误:模块“pyaudio”没有属性“__version__” - Traceback AttributeError: module 'pyaudio' has no attribute '__version__' AttributeError:'模块'对象没有运行可执行文件的属性'__version__' - AttributeError: 'module' object has no attribute '__version__' running the executable AttributeError:模块 'cv2' 没有属性 '__version__' - AttributeError: module 'cv2' has no attribute '__version__'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM