Open zty1122zty opened 7 months ago
Set PYTHONPATH:
import sys, os sys.path.append(os.path.abspath('path/to/directory/containing/pyd/files'))
int文件中line 6已如此设置,pyd files的目录为script。
import sys, os from multiprocessing import freeze_support
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = r'.\site-packages\PyQt5\Qt5\plugins'
os.chdir(os.path.dirname(file))
sys.path.append(os.path.abspath('script'))
sys.path.append(os.path.abspath('script.egg'))
if name == 'main':
if not hasattr(sys, 'frozen'):
sys.frozen = True
freeze_support()
# Import the 'main' module from the 'script' directory
import main
try:
# Call the 'startwin' function from the 'main' module
main.startwin()
except Exception as e:
import logging
logging.basicConfig(filename='log/Pystand-log.txt', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
logging.error(e)
已如此设置,但是只能识别py文件,而不能识别pyc或pyd
import sys, os
sys.path.append(os.path.abspath('script'))
Check File Extensions: Ensure that your .pyc and .pyd files have the correct file extensions and are compatible with the Python version you are using. .pyc files are compiled Python files, and .pyd files
Import Statements: In your code, make sure that you are using the correct import statements to load modules from the script directory. You should use the module name without the file extension when importing.
For example, if you have a file named mymodule.py in the script directory, you should import it like this: import mymodule
Permissions: Check read permissions for .pyc and .pyd files. Environment: Confirm sys.path changes are effective in your Python environment, especially when using tools like PyInstaller or cx_Freeze. Dependencies: Check for correct installation and accessibility of external libraries for .pyd files. Debugging: Add debugging statements to print sys.path values and verify file locations if issues continues.
尝试了以下方法均识别不到模块: 1.将script目录下的所有.py直接压缩并改为.egg放在.exe同级目录下 2.直接将script目录压缩为egg文件并放在exe同级 3.不压缩,将所有py文件替换为pyc文件 4.将所有py文件转化为pyd后放在script下
int文件配置如下:
只有将py放在script目录下且无压缩才能识别到。
请问如何处理才能正确识别到pyd文件以满足加密?