Decimoseptimo
Decimoseptimo

Reputation: 103

Python script works in PyCharm but throws path errors in windows cmd

I have a python script that runs succesfully from within pycharm terminal, setup as a virtual enviroment, but not from the windows terminal. I haven't set any windows enviroment variables.

Python is throwing FileNotFoundError when the script is loading external text files.

I came across this thread: Script running in PyCharm but not from the command line and i think the working directory is not correct when running from the windows terminal.

I do not understand the discrepancy. What does Pycharm different than the windows terminal? and how do i fix it?

Upvotes: 0

Views: 887

Answers (1)

cs95
cs95

Reputation: 402263

By default, PyCharm's current directory refers to the path to your PyCharm sandbox. If you've placed any files there, they'll load without any issues in PyCharm.

From the command line, however, you'll either need to specify a fully qualified path (to where those files actually are), or you'd need to move them to the directory from where you run your script.

Upvotes: 2

Related Questions