我正在使用python,并且正在运行使用同一目录中的文件的脚本,但它一直给我提示没有这样的文件。 顺便说一句,我使用该脚本文件作为模块来启用我的其他脚本文件。我使用的模块文件是从GitHub的项目:https://github.com/nik0spapp/unsupervised_sentiment(无监督的情感分析)为什么python在目录中有文件时说它没有目录中的文件?
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'
任何帮助将是最好的我到现在为止。谢谢!
指定完整路径时会发生什么? – 2014-08-27 20:45:59
你的意思是这样的? lib_path = os.path.abspath(“/ Users/chlee021690/Desktop/Programming/Python/Recommender System/unsupervised_sentiment /”)sys.path.append(lib_path) 导入情绪为unsupervised_sentiment – user2585578 2014-08-27 20:49:40
我的意思只是' dir/dir/emoticons.data'显然,dir意味着你的任何目标。 – 2014-08-27 20:50:12