How to call codes of a package directly without installing and importing module?
<p>Sorry I am a newbie. I have a python package created with one of my colleagues which is not available currently. Now I have to make small changes to module. I don't want to install the module. I want to just call the codes directly. Is there any way to copy files in the same folder and call it directly? </p>

<p>How can I use code of the package with minimal changes in it? </p>

<p>If you want to use anything defined within another file, you will have to <code>import</code> it.</p>

<p>To be able to <code>import</code> a module, you do <em>not</em> have to install it into the system-wide package directory. Python will look up modules you're trying to <code>import</code> on the <code>PYTHONPATH</code> environment variable; simply set that to the directory where you have the file:</p>

<pre><code>myproject/
   foo.py
   bar.py
</code></pre>

<p><em>foo.py:</em></p>

<pre><code>import bar

bar.baz()
</code></pre>



<pre><code>$ export PYTHONPATH=myproject
$ python myproject/foo.py
</code></pre>

<p>This enables Python to find <code>bar</code> in the directory <code>myproject</code>, outside the system-wide module installation directory.</p>

<p>You can also set up an isolated environment using <a href="http://virtualenv.pypa.io" rel="nofollow">virtualenv</a> and install the module there, which will take care of dependencies if it has any.</p>

python python-3.x