简体   繁体   English

我可以只使用PYC文件吗?

[英]Can I work with only PYC files

I have a program that uses couple of PY files. 我有一个使用几个PY文件的程序。 The code works perfectly till I use the PY files. 代码完美无缺,直到我使用PY文件。 However, for encryption when I delete the PY files and just keep the PYC files the program fails with message: ImportError: No module named abc 但是,对于加密,当我删除PY文件并只保留PYC文件时,程序失败并显示消息: ImportError:没有名为abc的模块

Any ideas/thoughts why python does not like the PYC here when everyting was working fine with the PY files? 任何想法/想法为什么python不喜欢PYC在这里PY文件正常工作时?

.pyc files contain byte-compiled python. .pyc文件包含字节编译的python。 These can be de-compiled again into very readable python code, and are not a protection from people studying the source code. 这些可以再次解编译成非常易读的python代码,并不是对研究源代码的人的保护。

If you do want to use this, you need to make sure all files are compiled, use: 如果你想使用它,你需要确保编译所有文件,使用:

python -m compileall /path/to/package

before removing the .py source files. 在删除.py源文件之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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