Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In general, the <a href="http://docs.python.org/tutorial/modules.html" rel="nofollow noreferrer">Modules</a> section of the Python tutorial is a good introduction for beginners on this topic. It explains how to write your own modules and where to put them, but I'll summarize the answer to your question below:</p> <p>Your Python installation has a <code>site-packages</code> directory; any python file you put in that directory will be available to any script you write. For example, if you put the file <code>MyLib.py</code> in the <code>site-packages</code> directory, then in your script you can say</p> <pre><code>import MyLib something = MyLib.myfunc() </code></pre> <p>If you're not sure where Python is installed, the Stack Overflow question <a href="https://stackoverflow.com/questions/122327/how-do-i-find-the-location-of-my-python-site-packages-directory">How do I find the location of my Python site-packages directory</a> will be helpful to you.</p> <p>Alternatively, you can modify <a href="http://docs.python.org/library/sys.html#sys.path" rel="nofollow noreferrer">sys.path</a>, which is a list of directories where Python looks for libraries when you use the <code>import</code> statement. Your <code>site-packages</code> directory is already in this list, but you can add (or remove) entries yourself. For example, if you wanted to put your <code>MyLib.py</code> file in <code>/usr/local/pythonModules</code>, you could say</p> <pre><code>import sys sys.path.append("/usr/local/pythonModules") import MyLib something = MyLib.myfunc() </code></pre> <p>Finally, you could use the <a href="http://docs.python.org/using/cmdline.html#envvar-PYTHONPATH" rel="nofollow noreferrer">PYTHONPATH</a> environment variable to indicate the directory where your <code>MyLib.py</code> is located.</p> <p>However, I recommend simply placing your <code>MyLib.py</code> file in the <code>site-packages</code> directory, as described above.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload