Using a folder for personal modules in Python
<p>I have created a folder named <code>C:\Python27\Lib\site-packages\perso</code> and inside I have put a file <code>mymodule.py</code>. The goal is to have this module accessible from any future Python script.</p>

<p>Let's do a <code>D:\My Documents\test.py</code> file:</p>

<pre><code>import mymodule   #fails
import perso.mymodule   #fails
</code></pre>

<p><strong>Why does it fail? How to import a module from <code>C:\Python27\Lib\site-packages\perso</code>? What are the best practice for using user-modules in all Python scripts of the same computer?</strong></p>

<ol>
<li>check PythonPath</li>
<li>create <code>__init__.py</code> to use perso as package</li>
</ol>

python module python-module