简体   繁体   English

ImportError:没有名为textract的模块

[英]ImportError: No module named textract

I have installed textract using pip install and ran the import command in jupyter notebook which is throwing the following error. 我已经使用pip install安装了textract并在jupyter notebook中运行了import命令,这会抛出以下错误。

I am on a windows machine and have two versions of python installed(2.7 and 3.6) using conda. 我在Windows机器上使用conda安装了两个版本的python(2.7和3.6)。 I have also added the paths to environment variables as suggested in other posts but still getting the error. 我还添加了环境变量的路径,如其他帖子中所建议但仍然出现错误。

import textract

ImportErrorTraceback (most recent call last)
<ipython-input-2-99b3b0e1733d> in <module>()
     1 #Code to extract pdf files
----> 2 import textract
    3 text = textract.process("C:/Users/username/Documents/Projects/Attachments/PDF/fileA.pdf")

ImportError: No module named textract 

EDIT: 编辑:

I was only successful in installing textract on python 2.7. 我只是成功地在python 2.7上安装textract。 I have added the below paths to the environment variables C:\\Users\\Username\\AppData\\Local\\Continuum\\anaconda3\\envs\\mypy27\\ C:\\Users\\Username\\AppData\\Local\\Continuum\\anaconda3\\envs\\mypy27\\Scripts---> this is where textract file is located C:\\Users\\Username\\AppData\\Local\\Continuum\\anaconda3\\envs\\mypy27\\Lib\\lib-tk C:\\Users\\Username\\AppData\\Local\\Continuum\\anaconda3\\envs\\mypy27\\Lib C:\\Users\\Username\\AppData\\Local\\Continuum\\anaconda3\\envs\\mypy27\\DLLs 我已将以下路径添加到环境变量C:\\ Users \\ Username \\ AppData \\ Local \\ Continuum \\ anaconda3 \\ envs \\ mypy27 \\ C:\\ Users \\ Username \\ AppData \\ Local \\ Continuum \\ anaconda3 \\ envs \\ mypy27 \\ Scripts- - >这是textract文件所在的位置C:\\ Users \\ Username \\ AppData \\ Local \\ Continuum \\ anaconda3 \\ envs \\ mypy27 \\ Lib \\ lib-tk C:\\ Users \\ Username \\ AppData \\ Local \\ Continuum \\ anaconda3 \\ envs \\ mypy27 \\ Lib C:\\ Users \\ Username \\ AppData \\ Local \\ Continuum \\ anaconda3 \\ envs \\ mypy27 \\ DLLs

UPDATE: I installed pypdf2 using pip install and tried importing it in juptyer notebooks. 更新:我使用pip install安装了pypdf2并尝试在juptyer笔记本中导入它。 It returned the same error. 它返回了同样的错误。 I was wondering if I am installing things incorrectly. 我想知道我是否正在安装错误的东西。

This worked for me on ubuntu 这对我在ubuntu上工作

1.Open terminal 1.打开终端

python -m venv env 
source ./env/bin/activate
sudo apt update
sudo apt install python-pip && pip install --upgrade pip
sudo apt install python-dev libxml2-dev libxslt1-dev antiword unrtf poppler-utils pstotext tesseract-ocr flac ffmpeg lame libmad0 libsox-fmt-mp3 sox libjpeg-dev swig
pip install textract

if you face any more errors: 如果您再遇到错误:

try 尝试

pip install https://pypi.python.org/packages/ce/c7/ab6cd0d00ddf8dc3b537cfb922f3f049f8018f38c88d71fd164f3acb8416/SpeechRecognition-3.6.3-py2.py3-none-any.whl
sudo apt install libpulse-dev
pip install textract

Now you will be able to import textract 现在您可以导入textract

import textract
text = textract.process("/home/user/textract_test.pdf")

This might be a workaround. 这可能是一种解决方法。

1.Uninstalled Anaconda and re-installed it. 1.卸载Anaconda并重新安装它。

2.Did not create any python 2.7 environment in anaconda and re-installed textract using pip along with all the other dependencies in the base anaconda command prompt. 2.不要在anaconda中创建任何python 2.7环境,并使用pip和base anaconda命令提示符中的所有其他依赖项重新安装textract。

3.Tried importing textract and it worked like a charm! 3.Tried导入textract,它就像一个魅力!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM