Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force recompile of py source in site-packages?

If I edit source of an installed package and delete the .pyc when I restart an app that uses it there is no new pyc generated in place indicating there is a cache elsewhere.

How do I force the update to source to be taken into account?

like image 428
user1561108 Avatar asked Sep 09 '16 10:09

user1561108


People also ask

How do I recompile a Python module?

You just have to run python -m compileall again. It will overwrite older . pyc files. You can pass it the -f switch to force rebuild even if timestamps are up to date (as per the documentation).

How do I compile all files in a directory in Python?

How do I compile all files in a directory in Python? python -m compileall <directory> -r 0 is equivalent to python -m compileall <directory> -l. Use N workers to compile the files within the given directory. If 0 is used, then the result of os.

When .PYC file is created?

When a Python source file (module) is imported during an execution for the first time, the appropriate . pyc file is created automatically. If the same module is imported again, then the already created . pyc file is used.


1 Answers

Go to the directory of the .py file and run python -m compileall ..

like image 56
acw1668 Avatar answered Oct 09 '22 22:10

acw1668