Emacs Python无法找到包/模块 [英] Emacs python not able to find package/module

查看:135
本文介绍了Emacs Python无法找到包/模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

emacs python解释器找不到我的tesseract(tesserocr),但是我可以在终端以及Spyder安装中使用tesseract. Emacs python解释器能够导入pytesseract,但找不到tesserocr.我收到以下错误:

My tesseract (tesserocr) is not found by the emacs python interpreter, but I am able to use tesseract on the terminal as well as in my Spyder installation. Emacs python interpreter is able to import pytesseract, but not find tesserocr. I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/eghx/agent18/project-gym/tests/thresholding.py", line 34, in image_to_string2
    print(image_to_string(img_open))
  File "/home/eghx/anaconda3/lib/python3.6/site-packages/pytesseract-0.1.7-py3.6.egg/pytesseract/pytesseract.py", line 122, in image_to_string
  File "/home/eghx/anaconda3/lib/python3.6/site-packages/pytesseract-0.1.7-py3.6.egg/pytesseract/pytesseract.py", line 46, in run_tesseract
  File "/home/eghx/anaconda3/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/home/eghx/anaconda3/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract': 'tesseract'

我跑步时

pytesseract.image_to_string(img)

但是,当我从终端而不是台式机打开EMACS时,我没有收到此错误.看来路径变量在emacs的桌面版本和终端版本中的继承方式不同.奇怪!

However I don't get this error when I open EMACS from a terminal instead of the desktop. It appears that the path variable is inherited differently in the desktop version and terminal version of emacs. ODD!

我在这里安装了anaconda:/path/to/anaconda3

I have anaconda installation here:/path/to/anaconda3

我已将这一行添加到我的init文件中以运行此特定的python安装

I have added this line to my init file to run this particular python installation

(setq python-shell-interpreter "/path/to/anaconda3/bin/python")

我使用conda install

which tesseract给出:

/path/to/anaconda3/bin/tesseract

$ echo $PATH给出:

/path/to/anaconda3/bin:/usr/local/sbin:/usr/lo....

我做了什么

我将sys.path从有效的Spyder IDE复制到了emacs python解释器,但仍然无法正常工作.

What I did

I copied the sys.path from the working Spyder IDE to emacs python interpreter and still didn't work.

我环顾四周,发现

I looked around and found this but the top answer does not pertain to my case, as my $PATH variable contains the necessary path.

有人可以引导我吗?我是菜鸟我有emacs 27,ubuntu 16和conda 4.5.0.

Can someone guide me? I am a noob. I have emacs 27 and ubuntu 16 and conda 4.5.0.

推荐答案

这可能是

This is a possible duplicate of OSError: [Errno 2] No such file or directory using pytesser

答案

import pytesseract

pytesseract.pytesseract.tesseract_cmd = 'path-to-tesseract-including-bin'

就我而言,

import pytesseract
pytesseract.pytesseract.tesseract_cmd = '/home/anaconda3/bin/tesseract'

通过在每个文件中键入以上内容,这只是使image_to_string正常工作的临时手段.

This is only a temporary hack to get image_to_string to work, by typing the above in every file.

为什么尚不知道为什么具有/home/anaconda3/bin$PATH变量不足以使其充分发挥作用. 似乎是一个长期的临时解决方案.

Why the $PATH variable having the /home/anaconda3/bin is not enough to get it to work sufficiently is not known. This seems to be a slighty long-term-temporary solution.

这篇关于Emacs Python无法找到包/模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆