简体   繁体   中英

clean up .pyc files in virtualenv stored in souce repository after the fact?

I've created a virtualenv for my project and checked it into source control. I've installed a few projects into the virtualenv with pip: django, south, and pymysql. After the fact I realized that I had not set up source control for ignoring .pyc files. Could there be any subtle problems in simply removing all .pyc files from my project's repository and then putting in place the appropriate file ignore rules? Or is removing a .pyc file always a safe thing to do?

That is fine, just remove them!

Python auto-generates them from the corresponding .py file any time it wants to, so you needn't worry about simply deleting them all from your repository.

A couple of related tips - if you don't want them generated at all on your local dev machine, set the environment variable PYTHONDONTWRITEBYTECODE=1 . Python 3.2 fixed the annoyance of source folders cluttered with .pyc files with a new __pycache__ subfolder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM