I have a project in PyCharm with multiple Python files, as well as some text files, which I want to export into .exe via PyInstaller (I'm on Win 7). The project uses some external modules installed inside venv via pip (PyInstaller is one of them).
I want to keep things simple and not use any modules outside venv in the build, for obvious reasons. However, when I try to execute the PyInstaller tool on the project folder, I get a permission error: PermissionError: [Errno 13] Permission denied. Using PyInstaller on the main.py inside the project builds it just fine at first glance, but running the .exe in cmd shows an error loading Python DLL. How do I do it right? Something tells me the spec should be created beforehand to include all files and modules used in the project.

To answer the question in the title, the
Argumentsyou specify in PyCharm are passed topyinstaller.exewhen you execute the tool. So it should be the path tomain.pyor the path to your.specfile, not$FilePath$which is a macro that gets replaced by the file that is currently open in PyCharm.You should definitely have a
.specfile, that is committed to version control. This makes your PyInstaller builds more consistent, and allows others to reproduce them easily. See https://pyinstaller.readthedocs.io/en/stable/spec-files.html