【发布时间】:2014-08-27 20:44:28
【问题描述】:
我正在使用 python,并且我正在运行使用同一目录中文件的脚本,但它一直给我一个错误,说没有这样的文件。 顺便说一句,我正在使用该脚本文件作为模块来启用我的其他脚本文件。我作为模块使用的文件来自 github 项目:https://github.com/nik0spapp/unsupervised_sentiment(无监督情绪分析)
Traceback (most recent call last):
File "sentiment_analysis.py", line 21, in <module>
import sentiment as unsupervised_sentiment
File "/Users/chlee021690/Desktop/Programming/Python/Recommender System/unsupervised_sentiment/sentiment.py", line 20, in <module>
from hp_classifiers import HpObj, HpSubj
File "/Users/chlee021690/Desktop/Programming/Python/Recommender System/unsupervised_sentiment/hp_classifiers.py", line 16, in <module>
from lexicon import Lexicon
File "/Users/chlee021690/Desktop/Programming/Python/Recommender System/unsupervised_sentiment/lexicon.py", line 17, in <module>
from datasets.emoticons_patch import patch_emoticons
File "/Users/chlee021690/Desktop/Programming/Python/Recommender System/unsupervised_sentiment/datasets/emoticons_patch.py", line 23, in <module>
emoticons_file = open("emoticons.data","r")
IOError: [Errno 2] No such file or directory: 'emoticons.data'
到目前为止,任何帮助对我来说都是最好的。谢谢!
【问题讨论】:
-
指定完整路径时会发生什么?
-
你的意思是这样吗? lib_path = os.path.abspath("/Users/chlee021690/Desktop/Programming/Python/Recommender System/unsupervised_sentiment/") sys.path.append(lib_path) 将情绪导入为 unsupervised_sentiment
-
我的意思是
/dir/dir/emoticons.data的完整路径显然 dir 意味着你的目录是什么。 -
您能告诉我们您用来调用相关文件的代码吗?如果我们看不到您在做什么,就很难找出问题所在。
-
我的意思是我可以看到 traceback 中发生了什么,但确切的上下文会有所帮助。
标签: python file directory ioerror