I have been using Linux for two days and Python for about 4 hours. Before that I used Mickeysoft for more than 20 years.

I like to keep project files in a directory heirarchy away from the application I am using to create them. I'm trying to program the example on page 17 in 'Learning Python'. Not being familiar with the Linux style file system doesn't help. Basically, IMPORT can't find myfile.py, which I did create. As I understand it, myfile.py is located in the home/Rory/PythonWork directory.

At this point I see three things that I could have done wrong:1. The '.py' extension. I think I read in one of the tutorials that you don't use the extension with import.2. I think this part is analogus to your 'subfolder': PythonWork. So back to the questions about whether it is a relative or an absolute path.3. I didn't put the _init_.py file in that folder or subdirectory.

I'm going to experiment with 1., I'll make the change in 3., but 2. remains due mainly to my unfamiliarity with Linux file systems. I noticed that Geany has a path browser built in. I'll see if that clears up my understanding of the pproblem.

If I'm not mistaken you want to be able to import modules from a specific directory whenever you invoke the interactive interpreter; regardless of what directory you invoke the interpreter from. You can do this by adding that folder to your path (though sys.path.append isn't the proper way to do this).

I on the other hand was trying to explain how to set up a package. This would involve creating a main script; and in a subdirectory within the same folder the main script was in (see previous post of mine) or a folder in your path, you would place your modules and a __init__.py file. You can not import a directory; there will never be slashes or quotes or .py in an import line. You can however import a package which basically amounts to the same thing. If this is too difficult you should just skip it for the time being. Many people don't learn how to use packages until quite a bit later.

Please look at my previous post again to see how the files are organized and make sure you realize that none of this has anything to do with the interactive interpreter. It has to do with executing a script. You can import packages in interactive mode but they will either need to be in a folder in your path, or in the current working directory.

at all to define sub-directories. The main.py file in mekires structure example is the file executed. For simplicity, change directory to that main.py file and execute it The parent directories are irrelevant at that point. If there are sub-directories In import statements, they are periods not foreward slashes.

If you are still confused, then you can check out the example below. I did this all on the terminal so you can actually see what i write to the file. For quick rundown: mkdir creates a directory, touch creates a file, cat prints off the file content, ls lists the current directory content, echo "some_string" >> filename writes some_string to the file filename. At worst case scenerio you should be able to at least duplicate a working example with this, since your using linux.

create directory example in ~/cd directory into examplecreate a new file called main.pylist files in directory (ls)write to the file on first line in main.py "from subfolder import module"write to the file on second line in main.py "print('running main')"print the content of what is in main.py (cat)make directory subfolderlist files and directories in current directory "example"create a new file in subfolder called __init__.pycreate a new file in subfolder called module.pywrite to the file on first line in the subfolder directory to file module.pyprint the content of what is in subfolder/module.pyexecute main.py via (python main.py) in the directory example(code can be python2.x or 3.x)