Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14040

Python3 Module has no asset erros

$
0
0

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)


Viewing all articles
Browse latest Browse all 14040

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>