简体   繁体   English

FileNotFoundError: [Errno 2] Pycharm 中没有这样的文件或目录

[英]FileNotFoundError: [Errno 2] No such file or directory in Pycharm

I'm pretty new with Python and finding some issues on a trivial code.我对 Python 很陌生,并且在一些琐碎的代码上发现了一些问题。 I'm using Pycharm together with Anaconda.我将 Pycharm 与 A​​naconda 一起使用。

This is my code:这是我的代码:

posSentences = open('rt-polarity-pos.txt', 'r')

print (posSentences.read())

There is no issue in reading the file and printing it out when running it/terminal.在运行它/终端时读取文件并打印出来没有问题。

But when I try to run the same command in the console I get:但是当我尝试在控制台中运行相同的命令时,我得到:

FileNotFoundError: [Errno 2] No such file or directory

I so checked the directories of the console, but they seem fine and are the same of the running file:我因此检查了控制台的目录,但它们看起来很好并且与正在运行的文件相同:

console setup控制台设置

Thank you for your help!谢谢您的帮助!

Python 解释器从Desktop\textan运行,但文件位于Desktop\textan\textan\目录中,因此 python 代码中文件的路径变为textan\rt...txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FileNotFoundError [Errno 2] 没有这样的文件或目录: - FileNotFoundError [Errno 2] No such file or directory: FileNotFoundError: [Errno 2] 没有这样的文件或目录? - FileNotFoundError: [Errno 2] No such file or directory? FileNotFoundError:[Errno 2]没有这样的文件或目录: - FileNotFoundError: [Errno 2] No such file or directory: FileNotFoundError:[错误2]没有这样的文件或目录,但是文件在那里 - FileNotFoundError: [Errno 2] No such file or directory, But the file is there FileNotFoundError: [Errno 2] 没有这样的文件或目录,但有一个文件 - FileNotFoundError: [Errno 2] No such file or directory but there is a file FileNotFoundError: [Errno 2] 没有这样的文件或目录:'ifconfig' - FileNotFoundError: [Errno 2] No such file or directory: 'ifconfig' 错误:FileNotFoundError:[Errno 2] 没有这样的文件或目录 - Bad: FileNotFoundError: [Errno 2] No such file or directory python:FileNotFoundError:[Errno 2]没有这样的文件或目录 - python: FileNotFoundError: [Errno 2] No such file or directory Python FileNotFoundError:[错误2]没有这样的文件或目录 - Python FileNotFoundError: [Errno 2] No such file or directory FileNotFoundError:[错误2]没有这样的文件或目录:错误 - FileNotFoundError: [Errno 2] No such file or directory: error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM