pandas “模块”对象没有属性“_version_”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23238394/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'module' object has no attribute '_version_'
提问by neanderslob
I'm screwing around with python and its pandas library but I keep running into a problem. While copying through a tutorial, I try to get the version number for a couple libraries, but when I do so, I get the following: AttributeError: 'module' object has no attribute '_version_'.
我正在使用 python 和它的 Pandas 库,但我一直遇到问题。虽然通过复制一个教程中,我试图让一对夫妇库的版本号,但是当我这样做,我得到如下:AttributeError: 'module' object has no attribute '_version_'。
Everything else works just fine, but it really doesn't like '_version_'for some reason. Anything I might be leaving out?
其他一切都很好,但'_version_'由于某种原因它真的不喜欢。我可能会遗漏什么?
See below for the exact code.
请参阅下面的确切代码。
import datetime
import pandas as pd
import pandas.io.data
from pandas import *
pd._version_
AttributeError: 'module' object has no attribute '_version_'
采纳答案by msvalkon
Use double underscores..
使用双下划线..
In [10]: pandas.__version__
Out[10]: '0.13.1'
Which is just a shorthand for pandas.version.version
这只是一个简写 pandas.version.version
PEP8suggests using __version__as the global variable to store a version number. Most libraries follow this and then offer a more readable variable or possibly a function which outputs the version in a usable form (like Django for example).
PEP8建议使用__version__作为全局变量来存储版本号。大多数库都遵循这一点,然后提供一个更具可读性的变量,或者可能是一个以可用形式输出版本的函数(例如 Django)。

