What if my scripts are saved in a different folder? Because I get an error that the module does not exist
3 ways that I know of:
The PYTHONPATH environment variable may be appended to by hand (not a great solution)
- import sys
-
sys.path.append(r"D:\Python\VideoCapture-0.9-1\Python24") # use the path to your script!
Thats a little better
My favorite:
Put your scripts all in one work folder until the work is complete.
After you have some utility/whatever that you use a lot and it is pretty much finished (probably never 100%), put it in
(on my system) D:\Python24\Lib\site-packages where python will automatically find it. If you want it in its own folder, you'll need a text file with the name of that folder in it. Save it with the .pth extension in the site-packages directory. Eventually, you'll learn to make a package from your work. Packages also live in the site-packages directory.
OK; I guess that's more like 5 ways of showing python where your scripts are.