ImportError: No module named pyrouge 解决

今天在运行decode代码时遇到的问题

pip install pyrouge

提示已经安装过
于是去/home/usr/.local/lib/python3.5/site-packages/下,按照官网的方法用pip install之后

pyrouge_set_rouge_path /absolute/path/to/ROUGE-1.5.5/directory

但是一直报错找不到文件,我发现这个项目的github上确实没有一个叫data的文件夹,后来又找到一个旧的版本,手动加了data文件夹下的东西,这样pyrouge_set_rouge_path不报错的,但是test的时候还是报错,可能版本的问题,少的不只是data文件夹,还有bin文件夹下的东西也不太一样

参考stackoverflow上一种方法,

git clone https://github.com/bheinzerling/pyrouge
cd pyrouge
python setup.py install

但是我这里又报错:

[Errno 13] Permission denied:
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or “root” account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

然后网上的一种解决方法是:chmod +a
但是又报错,chmod不能+a 可以递归的用-R,但是要用sudo权限,我没有这个权限

最后觉得实在很奇怪,明明是安装过的,为什么会找不到
于是我又去查python导入文件的问题
最终在项目文件中加了sys.path.append(“到python3.5/site-packages”)的绝对路径
也修改了PATHONPATH:export PYTHONPATH= /home/zzj/.local/lib/python3.5/site-packages/

最后终于不报这个错了gg

以及,如果是同级目录文件,但是加了路径也访问不到的,可以在目录下添加一个空的init.py文件,才会被视为一个模块

猜你喜欢

转载自blog.csdn.net/BeforeEasy/article/details/80490609