Reputation: 5531
I cannot compile with Python 3, i.e. the .pyc files are not generated.
For example:
python -m py_compile test.py
generates test.pyc
Hovewer,
python3 -m py_compile test.py
does not generate test.pyc
test.py
print("hello world")
Why?
Upvotes: 1
Views: 398
Reputation: 2265
In Python 3, you can find .pyc file in the __pycache__
directory, beside your test.py
script.
$ python3 -m py_compile test.py
$ ls __pycache__
test.cpython-36.pyc
Use py_compile
module:
>>> import py_compile
>>> py_compile.compile('test.py')
See: https://docs.python.org/3/library/py_compile.html
Upvotes: 1