0

I'm using an old version of Python (v3.2) on a USB standalone environment (Portable Python) for simplicity and educational purposes since it works virtually on any computer without any software needing to be installed. I was working on functions and modules a few days ago on with no issue. The next day I tried to continue further but I now kept getting an error message that the module I had written and was trying to import did not exist. This is the case for any new programs I created after that day.

Just out of curiosity I tried importing that same module into any older python programs I had saved on my USB, no problems.

I tried deleting and rewriting files. Still the same issue. As far as I know the directories and folder placements are correct. I tried searching online but nothing I can see pertaining to this particular problem.

What gives?

6
  • 2
    What gives? We don't know, because you have not shown us the code, or the file structure layout, or the full error message, or ... anything. Commented May 26, 2024 at 21:42
  • Unrelated: Portable Python is incredibly out of date. It hasn't been maintained for a decade. Get something newer. Maybe WinPython, if you still want something portable. Commented May 26, 2024 at 21:42
  • @JohnGordon see attached ibb.co/SyyspSh ibb.co/NC9Lq9m ibb.co/87v6340 ibb.co/94GYzYN I didn't know what specifics people would ask for first. I didn't want to clutter up the post with unnecessary info. Commented May 27, 2024 at 18:48
  • @user2357112 Is WinPython completely standalone or does it need to have some sort of installation on the computer being used? Commented May 27, 2024 at 18:49
  • It wont let me edit the but workable image links should be at the very bottom at Chi Duong Trong comment. Commented May 27, 2024 at 19:02

1 Answer 1

1

Are you sure you are running from the right directory? If you have a file main.py in a directory /example/directory/which looks like this:

# main.py
import os
print(os.getcwd())

And you run python3 directory/main.py from /example/ you get

/example/

But if you run python3 main.py from /example/directory/ you get

/example/directory/

So the working directory of a python script is where you run it from, not where the script actually is.

Perhaps the problem is that you are running the script from a different directory it won’t find the module but if you run it from the directory the module is in, it should find the module.

This might not be the problem, but it’s worth a try and I hope you learned something.

Note, the reason I used python3 not just python is because on my system, if I run python for some reason it runs python 2.7

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for responding. I've attached the screenshots below of what I've done. As far as I can tell everything is in the right place. ibb.co/SyyspSh ibb.co/NC9Lq9m ibb.co/87v6340 ibb.co/94GYzYN

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.