*.pyc files without using absolute path

  • Thread starter Alexander Hoffmann
  • Start date
A

Alexander Hoffmann

Hello,

I have a project with a number of python modules, which means there are
several *.py files all in the same folder /usr/local/myproject/*.py .
I ran the program to test it and of course as a result the *.pyc files were
created. Since everything was running fine I gave the *.pyc files (not the
source) to a friend of mine. He put it in his home dir and executed the
program. Then there was an error because some of the modules tried to import
the others with absolute path "/usr/local/myproject/*.pyc) which did not
exists on my friend's machine.
To get more clarification I searched for the absolute path in my local *.pyc
files (grep -a "/usr/local/myproject" *.pyc) and indeed there were a lot of
matching lines.
How can I make Python create *.pyc files without absolute path when all the
modules (besides built-in like "string", "os" etc. ) are in the same dir ?

Thanks to you !
Alex
 
T

Thomas Heller

Alexander Hoffmann said:
Hello,

I have a project with a number of python modules, which means there are
several *.py files all in the same folder /usr/local/myproject/*.py .
I ran the program to test it and of course as a result the *.pyc files were
created. Since everything was running fine I gave the *.pyc files (not the
source) to a friend of mine. He put it in his home dir and executed the
program. Then there was an error because some of the modules tried to import
the others with absolute path "/usr/local/myproject/*.pyc) which did not
exists on my friend's machine.
To get more clarification I searched for the absolute path in my local *.pyc
files (grep -a "/usr/local/myproject" *.pyc) and indeed there were a lot of
matching lines.
How can I make Python create *.pyc files without absolute path when all the
modules (besides built-in like "string", "os" etc. ) are in the same dir ?

The builtin compile function can do that.

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top