Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMohammad Aslam
6,053 PointsCan't get to the correct directory for Die D6 classes
I keep getting an error message when I try to get to the yatzy directory in the python shell.
"/usr/local/pyenv/versions/3.5.0/bin/python: can't find 'main' module in 'yatzy/pycache/'"
Can anyone help with this?
2 Answers
Mohammad Aslam
6,053 PointsYes, its in workspaces.
Im using this command "python yatzy/pycache/" after which I get the message "/usr/local/pyenv/versions/3.5.0/bin/python: can't find 'main' module in 'yatzy/pycache/' "
If I go into python shell directly, here are the commands and error messages I have gotten:
from yatzy/pychache/dice import D6
File "<stdin>", line 1
from yatzy/pychache/dice import D6
^
SyntaxError: invalid syntax
from dice import D6
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'dice'
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsHey Mohammad Aslam
So even though __pycache__
can be a folder that is generated when your script is run. This is usually not a folder you worry about trying to import your code from. The code inside there is byte code, no longer really Python.
There should be a file called dice.py
in that folder. This means from your python shell you can treat the yatzy and dice as a module to import from.
So instead of from yatzy/pycache/dice
try removing the pycache. Also use .
as the separator.
It would look something like this from yatzy.dice import D6
, then you have access to D6 inside your shell so you could create instances like dice_6 = D6()
Let me know if that helps with your problem!
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsChris Howell
Python Web Development Techdegree Graduate 49,702 PointsCould you provide a few more details so I can try to help? Here they are.