I'm sure snippsat's advice is excellent. I just don't understand it!
Not sure if you are using windows or Linux. I don't know anything about windows. Apparently, you can change your path variable in windows like this:
Quote:Changing the Path Environment Variable
Because the Path environment variable is a list of many paths, you need to be careful when modifying it, so that you don’t overwrite the whole Path with just one path.
Typically, if you’re going to be doing that from PowerShell as a temporary environment variable, then you’ll need to append the new value with string concatenation:
$env:Path = "$env:Path;C:\new\path"
If you can do the above, the rest should work just like it does in Linux:
Send the module / package you have made to your friend. It is just a text file.
You don't even need to make mypackage.py executable.
Tell your friend to create a directory on his / her computer similar to this: /home/username/myPython/my_modules/ (just an example path)
You can use any name you like. Put the file mypackage.py in the directory /home/username/myPython/my_modules/
Now you have to tell the operating system about this path to files.
Then, when you write:
import mypackage the operating system will look in
/home/username/myPython/my_modules/ will find
mypackage.py and make it available to your friend's programme.
You can temporarily append any path to your operating system $PATH variable from within a Python programme like this:
import sys
# tell the operating system about the new path to files
# temporarily append this path to $PATH
sys.path.append('/home/username/myPython/myModules/')
# now you can import mypackage, or any other home-made module, easily.
import mypackage
# below follows code for any programme you wish to writeIn Linux you can also permanently add a path to your system by modifying the file .bashrc
This file is normally in your home directory.
Put this line at the end of the .bashrc file on a new line, using a simple text editor.
Quote:export PATH=/some/new/path:$PATH
Then in a bash terminal, apply the change like this on the command line:
Quote:source ~/.bashrc
Now, the path: /some/new/path is always be available to your search paths variable $PATH, so you don't need to do this:
import sys
# tell the operating system about the new path to files
# temporarily append this path to $PATH
sys.path.append('/home/username/myPython/myModules/')