I am trying to run ex. 25 on macOS and I am having problems. When trying to import the module, I receive the following error. In other posts on this forum, I have seen resolutions for those running Windows, but nothing for macOS. Please help, and thanks in advance!
Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ex25
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'ex25'
The output of pwd seems to show that you’re not in the folder where ex25.py3 is. You can only import file modules from your current location. Could that be the issue?
Yes, what @florian said and also don’t forget to save the file. If you have ex25.py written, but not saved yet, then it’ll either be missing or empty on the disk and python can’t load it.
Okay that is weird, but I don’t understand why you are in that system folder to begin with. You should have the Python executable in your path so you can launch Python everywhere.
Can you go to your documents folder where you originally saved the file, start Python there and try the import?
You are running python from its library location as @florian said. You really don’t want to be in there hacking about.
Just like other documents, you’ve saved files in a user file system location like user/somebody/documents which is fine.
When you run the python interpreter, it can be from anywhere on the file system. But it will only find files in that location. So running it in the file system (bin) won’t find ex25.py because it’s not there.
Run the python command from the location where all your scripted files are.
Also I’d strongly advise not following Windows solutions on OSX
@florian…hindsight being 20/20, I have no earthly idea. I looked back over all of the setup and nothing in @zedshaw’s documentation said to do that. Not a great idea.