Created a project in PyCharm with one file module1.py:
print('Hello module World!') Run the Run button.
Why in the project directory does not create a file with the bytecode module1.pyc?
Created a project in PyCharm with one file module1.py:
print('Hello module World!') Run the Run button.
Why in the project directory does not create a file with the bytecode module1.pyc?
Why in the project directory does not create a file with the bytecode module1.pyc?
Because in Python 3, such files are written to the __pycache__ directory (see PEP 3147 ), which your IDE will most likely hide so as not to trash the appearance of the project directory.
If you start a module by passing it from the command line (or if your IDE does it for you): python ваш_модуль.py , then it is recompiled each time ( .pyc not created) . Compare this with running python -mваш_модуль that imports ваш_модуль and therefore the .pyc file in the __pycache__ directory can be written.
Also check if you have rights to create a subdirectory (from which user python is running). You can try compiling the modules yourself:
>>> import py_compile >>> py_compile.compile('ваш_модуль.py') Another option is that the creation of .pyc disabled, for example, due to the non-empty PYTHONDONTWRITEBYTECODE environment variable or python -B command line option.
Perhaps, in the Pycharm settings you have enabled ignoring these files. Like for example with me.
Here is the documentation for customizing the display https://www.jetbrains.com/help/pycharm/2016.1/file-types.html .
I do not understand why you need them. On the deployment they do not affect the version control system, either.
module1.cpython-35.pyc was created in the __pycache__ folder. But only by running the interpreter from the command line. I will continue to understand how to work with bytecode in the IDE. - Alexey NikolaevAs far as I know, * .pyc files are created when importing a module.
module2.py:
import module1.py Get module1.cpython-35.pyc
Source: https://ru.stackoverflow.com/questions/579884/
All Articles