aws-samples/aws-cdk-intro-workshop

Cannot import the HitCounter Module

Amanda-Ruzza opened this issue · 4 comments

Describe the bug

I'm encountering an issue with downloading the hitcounter module on the workshop.
I looked at previous (closed) tickets, and tried to troubleshoot it that way, however, it seems that the module does NOT exist.
I searched for the module on PyPi, and couldn't find it in the website neither.
I'm working straight out of the AWS Cloud9 IDE, using the Python CDK v2.
Any suggestions on how I could debug this would be very appreciated.

  File "app.py", line 5, in <module>
    from cdk_workshop.cdk_workshop_stack import CdkWorkshopStack
  File "/home/ec2-user/environment/cdk_workshop/cdk_workshop/cdk_workshop_stack.py", line 8, in <module>
    from .hitcounter import HitCounter
ModuleNotFoundError: No module named 'cdk_workshop.hitcounter'

Subprocess exited with error 1

### Expected Behavior

For the ``HitCounter module`` to be imported into the ``app.py`` file.

### Current Behavior

~/environment/cdk_workshop (master) $ cdk deploy
Traceback (most recent call last):
File "app.py", line 5, in
from cdk_workshop.cdk_workshop_stack import CdkWorkshopStack
File "/home/ec2-user/environment/cdk_workshop/cdk_workshop/cdk_workshop_stack.py", line 8, in
from .hitcounter import HitCounter
ModuleNotFoundError: No module named 'cdk_workshop.hitcounter'
Subprocess exited with error 1

Reproduction Steps

See code snippet above

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2

Section

Write Constructs, Define the Hit Counter API

Browser

Chrome

Language

Python

Hi @Amanda-Ruzza,
the hitcounter is something you set up as part of the CDK workshop. So no need to search on PyPi :)
I can successfully run a cdk synth.

Here my cdk_workshop_stack.py, the import of the hitcounter is similar to your setup also on line 8.
image

The directory structure is as follows

image

I played a bit around and I got also your error message after renaming hitcounter.py to something else (here hitcounter2.py).
image

Could you provide details on the setup of your project (file/ directory structure)?

Cheers,
Stefan

Hey @Amanda-Ruzza, the comment that @stefanfreitag left was helpful. The hitcounter module is created as part of this project - make sure that you created the hitcounter module in the right file and folder and that you're importing it from the right location.

If you're still running into issues, please share your project file structure, and the contents of the hitcounter file as well as the files you are trying to implement the hitcounter module.

Got it, thank you for the support. I was following the AWS Workshop using the Cloud9 IDE on my sandbox account which doesn't exist anymore, however, I'll try it out on my local environment.

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.