cannot run program from terminal using pycharm 2017
Answered
|
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. The line that the terminal does not like is:
Again, this line works fine with 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.
|
Please sign in to leave a comment.
I have also tried using the full path of the document
Hi Kyle! When you execute a script in PyCharm it will set the script folder as a working directory. In your case it will be
you can check it inside Run Configuration to be sure. Then assuming
is inside
the reference
is correct indeed. Meanwhile if you open the console PyCharm will set a Project root as a working directory, in your case it will be
so the previous path to xlsx file will become obviously not correct. The absolute system path should work here but it's hard to tell what exactly is wrong without looking in your code and path provided. I would use
to get the working directory in runtime and debug the problem. If you are allowed to share the project or a related part of it - please contact our support with additional details pycharm-support@jetbrains.com. Feel free to comment here also but this thread is not private.
I tried changing my working directory by using
Users/kylefoley/PycharmProjects/inference_engine2
but that did not work. Incidentally the temp_proofs doc is in directory
Users/kylefoley/PycharmProjects/inference_engine2
so when I move it into the same folder as the script and change the line to
File "/Users/kylefoley/PycharmProjects/inference_engine2/inference2/Proofs/prove.py", line 36, in <module>
wb4 = load_workbook('Users/kylefoley/PycharmProjects/inference_engine2/inference2/Proofs/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: 'Users/kylefoley/PycharmProjects/inference_engine2/inference2/Proofs/temp_proof.xlsx'
Kyle, looks like you forgot an initial slash in the path:
should be
Thanks, that did it.
Also by the way, the syntax
print(os.getcwd())
NameError: name 'os' is not defined
did not work.
Oh yeap, you have to import os module first: