Python Forum
'module' object is not callable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'module' object is not callable
#1
Hi All,,

I'm a rookie with Python and as you can see from above I'm getting the following message. If I remove the xport line I receive no errors. Am I calling xport the wrong way?

Thanks

Error:
"module' object is not callable"
import pandas as pd
import pyodbc
import xport

# Trusted Connection to Named Instance
try:
    connection = pyodbc.connect('DRIVER={ODBC Driver 17 for SQL Server};SERVER=laptop\MS_SQLEXPRESS;DATABASE=CheckData;Trusted_Connection=yes;')
except Exception as err:
    print('Exception occured while trying to create a connection ', err)
else:
    try:

        sql_query = pd.read_sql_query('''EXEC sp_Rtest''', connection) 
        # here, the 'connection' is the variable that contains your database connection information from step 2

        df = pd.DataFrame(sql_query)

        pd.set_option("display.max_columns", None)
        

        df.head()    

       with open("C:/Users/myfiles/my_file.xpt", "wb") as f:xport(df,f)


    except Exception as err:
       print('Exception occurred while fetching records ', err)
    else:
        print('')
    finally:
      print('')
finally:
    connection.close()
buran write Nov-04-2021, 02:31 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply
#2
Please, post the full traceback you get, in error tags
(Nov-04-2021, 02:17 PM)Racer_x Wrote: Am I calling xport the wrong way?

It looks like that. Did you check the examples in the docs
They do import xport.v56 or import xport.v89
Then they use xport.v56.load() (or .loads()) and bind the return value to a name or xport.v56.dump() ( or .dumps()).

In your code you try to call xport() and you get the above error. Also even if it miraculously worked, you just throw away the return value.

Also note that for v89 only loads/dumps are implemented.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Nov-04-2021, 02:44 PM)buran Wrote: Please, post the full traceback you get, in error tags
(Nov-04-2021, 02:17 PM)Racer_x Wrote: Am I calling xport the wrong way?

It looks like that. Did you check the examples in the docs
They do import xport.v56 or import xport.v89
Then they use xport.v56.load() (or .loads()) and bind the return value to a name or xport.v56.dump() ( or .dumps()).

In your code you try to call xport() and you get the above error. Also even if it miraculously worked, you just throw away the return value.

Also note that for v89 only loads/dumps are implemented.
Reply
#4
Here's the full error:
Error:
PS C:\Users\Test Files> python -u "c:\Users\Test Files\xport.py" Exception occured while fethcing records 'module' object is not callable Exception occured while fethcing records 'module' object is not callable
Reply
#5
There is one more problem - your own file is named xport.py and at the moment it try to import it, not the xport package. Rename your file to something else.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
(Nov-04-2021, 03:15 PM)buran Wrote: There is one more problem - your own file is named xport.py and at the moment it try to import it, not the xport package. Rename your file to something else.

BAM!!!! You're a Genius!!! Thanks Buran!!! That was it, I'll continue to work on it but as soon as I changed the name certain attributes became available
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 456 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  TypeError: 'NoneType' object is not callable akbarza 4 922 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,262 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Need help with 'str' object is not callable error. Fare 4 779 Jul-23-2023, 02:25 PM
Last Post: Fare
  working with TLV module Object Jennifer_Jone 3 1,077 Mar-14-2023, 07:54 PM
Last Post: Jennifer_Jone
  TypeError: 'float' object is not callable #1 isdito2001 1 1,046 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  'SSHClient' object is not callable 3lnyn0 1 1,132 Dec-15-2022, 03:40 AM
Last Post: deanhystad
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,375 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov
  API Post issue "TypeError: 'str' object is not callable" makeeley 2 1,834 Oct-30-2022, 12:53 PM
Last Post: makeeley
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 5 1,495 Aug-28-2022, 07:11 AM
Last Post: Melcu54

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020