Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'module' object has no attribute '_version_' [closed]

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_'.

Everything else works just fine, but it really doesn't like '_version_' for some reason. Anything I might be leaving out?

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_'
like image 763
neanderslob Avatar asked Apr 23 '14 08:04

neanderslob


People also ask

How do you fix an object that has no attribute?

The Python "AttributeError: 'list' object has no attribute" occurs when we access an attribute that doesn't exist on a list. To solve the error, access the list element at a specific index or correct the assignment.

How do you fix a module object is not callable?

How to fix typeerror: 'module' object is not callable? To fix this error, we need to change the import statement in “mycode.py” file and specify a specific function in our import statement.

Has no attribute module Python?

The Python "AttributeError: module has no attribute" occurs for multiple reasons: Having a circular dependency between files, e.g. file A imports file B and vice versa. Having a local module with the same name as an imported module. Having an incorrect import statement.

What is the attribute error in Python?

AttributeError can be defined as an error that is raised when an attribute reference or assignment fails. For example, if we take a variable x we are assigned a value of 10. In this process suppose we want to append another value to that variable. It's not possible.


1 Answers

Use double underscores..

In [10]: pandas.__version__
Out[10]: '0.13.1'

Which is just a shorthand for pandas.version.version

PEP8 suggests 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).

like image 77
msvalkon Avatar answered Oct 17 '22 23:10

msvalkon