user2599291
user2599291

Reputation: 1

Python3 Module has no asset erros

I have never come across this before when working with Python. When I type:

import areas - no errors - import works

when I type:

areas.triangle(3,5) : I get this error:

AttributeError: module 'areas' has no attribute 'triangle'

What I can see from looking inside the package folder is that there are no functions for anything the areas module is supposed to do.

When I type

dir(areas) I get

['Test', 'Tester', 'builtins', 'cached', 'doc', 'file', 'loader', 'name', 'package', 'path', 'spec', 'config', 'exception', 'parameters', 'subroutines', 'test', 'tester', 'util']

I checked

print(areas.file) I get

/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/areas/init.py

I can't figure out what is happening. Anyone have any similar issues or what I am doing to cause the issue (Wrong version of areas, wrong directory)

Thanks for the help. Again, no errors when I import the areas module in python3

I attempted to do this same import using python- (not python3)

I assume that if the package imports without errors, it thinks its okay?

---------- Follow Up.

I was following my python instructor online. He imported the 'areas' package and then did a cat on areas.py and got the following response. cat areas.py

import math

def triangle(base, height):

return base*height/2

def rectangle(base, height):

return base*height

def circle(radius):

return math.pi*(radius**2)

Upvotes: 0

Views: 44

Answers (1)

user2599291
user2599291

Reputation: 1

UGH... Really sorry for the confusion. But I appreciate all the responses, and I did learn from them.

The instructor had actually "CREATED' the file called areas.py and added the code to it that I showed. I created the file areas.py and then EVERYTHING wored great.

Again, I appreciate the help. (Sorry I am new to Python)

Upvotes: 0

Related Questions