我在Mac上使用Pyinstaller。我能够通过运行pyinstaller --onefile --paths /Users/wnba/PycharmProjects/a2_part3/venv/lib/python3.7/site-packages gp.py
创建可执行文件,但是当我运行创建的文件gp
时,它出现了一个奇怪的错误,提示[3723] Failed to execute script gp
exitTraceback (most recent call last):
File "gp.py", line 56, in <module>
File "gp.py", line 12, in read_file
FileNotFoundError: [Errno 2] No such file or directory: '-B'
我在第12行附近的gp.py如下所示:
import numpy as np
import sys
import re
import gplearn
from gplearn.genetic import SymbolicClassifier
from sklearn.metrics import roc_auc_score
def read_file(path):
with open(path, 'r') as sourcefile: # this is line 12
sourcelines = sourcefile.read()
我解析args的方式是:
read_file(sys.argv[1])
能否请您指出出什么问题了?非常感谢