[英]Program runs in Pycharm but not in terminal
I often run a program using terminal because that speeds things up by a factor of 3. I recently upgraded from a 2016 version of Pycharm to a 2017 version and now I can no longer run the program in terminal. 我经常使用终端运行程序,因为这样可以使速度提高3倍。我最近从2016版的Pycharm升级到了2017版,现在我不再可以在终端中运行该程序。 The line that the terminal does not like is: 终端不喜欢的行是:
wb4 = load_workbook('../temp_proof.xlsx')
Again, this line works fine with Pycharm. 同样,此行与Pycharm配合良好。 I went to the terminal and made sure it was in the right directory and when I pressed ls, that file is in the directory. 我去了终端,确保它在正确的目录中,当我按ls时,该文件在目录中。
Here is the terminal error message:
File "/Users/bobsmith/PycharmProjects/inference_engine2/inference2/Proofs/prove.py", line 36, in <module>
wb4 = load_workbook('../temp_proof.xlsx')
File "/Library/Python/2.7/site-packages/openpyxl/reader/excel.py", line 151, in load_workbook
archive = _validate_archive(filename)
File "/Library/Python/2.7/site-packages/openpyxl/reader/excel.py", line 115, in _validate_archive
archive = ZipFile(filename, 'r', ZIP_DEFLATED)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/zipfile.py", line 756, in __init__
self.fp = open(file, modeDict[mode])
IOError: [Errno 2] No such file or directory: '../temp_proof.xlsx'
For some reasons I had to put a slash in front of Users like so: 由于某些原因,我不得不在用户前面加一个斜杠,如下所示:
wb4 = load_workbook('/Users/bobsmith/PycharmProjects/inference_engine2/inference2/temp_proof.xlsx')
I thought I tried that before, but this time it worked. 我以为以前尝试过,但是这次可以了。 It also might be the case that I had to reconfigure my Pycharm working directory which I did. 也可能是我不得不重新配置我的Pycharm工作目录的情况。 So I'm not sure what the real cause was. 所以我不确定真正的原因是什么。
Its seems to get the abs path from the temp_proof.xlsx file location. 它似乎从temp_proof.xlsx文件位置获取abs路径。 do this below steps 请按照以下步骤操作
This will work 这会起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.