How to deal with paths with spaces on Linux when coding in Python 2.7?
<p>I have a python script that process files in a directory on Linux Mint. Part of the code is like the following:</p>

<pre><code>path_to_dir = "/home/user/Im a folder with libs to install/"

if os.path.isdir(path_to_dir):
    print "it can locate the directory"
    os.chdir(path_to_dir) # everything ok here :D
    subprocess.call(['./configure'], shell = True)
    subprocess.call(['make'], shell = True)
    subprocess.call(['make install'], shell = True) # problem happens here
</code></pre>

<p>When executing <code>subprocess.call(['make install'], shell = True)</code> it throws this error:</p>

<pre><code>/bin/bash: /home/user/Im: No such file or directory
make[3]: *** [install-libLTLIBRARIES] Error 127
make[2]: *** [install-am] Error 2
make[1]: *** [install-recursive] Error 1
make: *** [install-recursive] Error 1
</code></pre>

<p>How can I deal with spaces in paths when executing <code>subprocess.call(['make install'], shell = True)</code>? (I'm using Python 2.7)</p>

<p>Edit: I found out the source of the errors: the Makefile of the libraries I'm using (downloaded from somewhere on Internet) don't support spaces in the path.</p>

<p>I tested the answer given here using this code in the terminal located in the path "/home/user/Im a folder with libs to install/" and using a root account:</p>

<pre><code>./configure
make
make install /home/user/Im\ a\ folder\ with\ libs\ to\ install/Makefile
</code></pre>

<p>It gives me the same error:</p>

<pre><code>/bin/bash: /home/user/Im: No such file or directory
[install-libLTLIBRARIES] Error 127
make[3]: se sale del directorio «/home/user/Im a folder with libs to install/»
make[2]: *** [install-am] Error 2
make[2]: se sale del directorio «/home/user/Im a folder with libs to install/»
make[1]: *** [install-recursive] Error 1
make[1]: se sale del directorio «/home/user/Im a folder with libs to install/»
make: *** [install-recursive] Error 1
</code></pre>

<p>It can locate the folder, but it seems that, internally, it passes the path to Linux bash with no scape characters.</p>

<p>I'm accepting nafas as the answer because he helped me to locate the source of the problem.</p>