Let's say I have a Python file which I would like to import and use anywhere else; how can I write a Python code to insert the path of this module to sys.path
permanently?
Asked
Active
Viewed 1,215 times
0

jonrsharpe
- 115,751
- 26
- 228
- 437
1 Answers
-1
You could set your PYTHONPATH environment variable. This could be done by setting it in the /etc/profile file if you are on Linux.
-
Is there a way to do this using python code instead of cmd, and for windows – Apr 12 '14 at 21:55
-
Rather than modifying the path, you could include your package in c:\Python27\Lib\site-packages (or the equivalent directory for your version of Python). That's the purpose of that directory. – mkimball Apr 12 '14 at 21:57
-
@Just4Help Windows does have environment variables as well. They can be set from within the control panel http://www.computerhope.com/issues/ch000549.htm – niklasfi Apr 12 '14 at 21:59