Home > Blockchain >  Python3: TypeError: 'module' object is not callable
Python3: TypeError: 'module' object is not callable

Time:06-22

I keep trying to run a bit of python on mac terminal, and I'm hit with the following error: "TypeError: 'module' object is not callable"

Reference code:

import re
import pathlib as Path
mypath = Path('users/pranav/Desktop/sir/samplenames.txt')

Could someone break down the error for me and explain what I should do to fix it?

I also tried to fix it using sys, however, before I could even work through it I was returned an error stating: AttributeError: 'list' object has no attribute 'dirname'

Code w/ sys:

import sys
print(sys.path.dirname())
import re
import pathlib as Path
mypath = Path('/users/pranav/Desktop/sir/samplenames.txt')

Any help would be greatly appreciated

CodePudding user response:

from pathlib import Path

SCR_DIR = 'C:\\users\\pranav\\Desktop\\sir'

mypath = Path(SRC_DIR, "samplenames.txt")
  • Related