Ask coding questions

← Back to all posts
Importing Python files
MartinRose (15)

I have had problems importing my python files on but I can do it when I do it locally. I have been searching around to get an answer but all the methods have come up empty, maybe someone here can help. I have tried to import with these commands:
import TommyTheSegest
from TommyTheSegest import *
from TommyTheSegest import initiate

I named it that because I wanted to make sure that I did not collide with a command that it was trying to import from elsewhere, at least that was my intent. When I try those commands, I think my Linux tries to install an external command and I have no idea why. I get this error to be more exact:

" Installing fresh packages

Collecting TommyThe Segest
Could not find a version that satisfies the requirement TommyTheSegest (from versions: )
No matching distributions found for TommyTheGreatest
You are using pip version 19.0.0, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command. package installation failed!

I am familiar with some Linux and sees that the pip command has less to do with Pythong and more with the Linux itself. I tryed typing the command in the console just in case but of course that did not work. What am I doing wrong?

Thanks in advance
A frustrated beginner

Answered by ArchieMaclean (926) [earned 5 cycles]
View Answer
ArchieMaclean (926)

Thank you for the great explanation of your problem!

You've just made one tiny error - the other file (TommyTheSegest) is a python file, so it should be called Like this:

Python was looking for a python file and since it couldn't find it, it tried to download one using pip, causing the error.
Once you've renamed the file, the import error should be resolved - there are also a couple of errors that are in the file that are unrelated to this problem, but I'll let you work those out yourself.

Please mark this as the answer if it solved your problem :)

MartinRose (15)

@ArchieMaclean Thank you so much. I didn't notice that. Was driving me mad.


@ArchieMaclean In the picture, I think the background is in dark mode.

CodeNinja418 (1)

@MartinRose I still don't understand.