[英]ModuleNotFoundError: No module named 'camelot' | Works in Jupyter Notebooks but not VSCode
Goal: to get a working version of this tutorial with PDF , via.目标:通过PDF获得本教程的工作版本。 Visual Studio Code.
视觉工作室代码。
I am trying to install camelot
, via.我正在尝试通过安装
camelot
。 VSCode , using Poetry, but am having dependency problems. VSCode ,使用诗歌,但有依赖问题。
This works in Jupyter Notebooks (bottom of post), but I am attempting to append to an existing.py project.这适用于Jupyter Notebooks (帖子底部),但我正在尝试将 append 转换为 existing.py 项目。
Code:代码:
import glob
import camelot
import pandas as pd
import multiprocessing.dummy as mp
import ctypes
from ctypes.util import find_library
find_library("".join(("gsdll", str(ctypes.sizeof(ctypes.c_voidp) * 8), ".dll")))
PDF_LIST = glob.glob('../data/gri/reports/*.pdf')
def scrape_tables(pdf_filename):
tables = camelot.read_pdf(pdf_filename)
print("Total tables extracted:", tables.n)
return tables
p = mp.Pool(len(PDF_LIST))
pdf_esg_scraped = p.map(scrape_tables, PDF_LIST)
pip install camelot
: pip install camelot
:
danielbellhv@PF2DCSXD:/mnt/c/Users/dabell/Documents/GitHub/workers-python/workers/data_simulator/src$ pip install camelot
^[[A^[[A
Requirement already satisfied: camelot in /home/me/.local/lib/python3.8/site-packages (12.6.29)
Requirement already satisfied: Elixir>=0.7.1 in /home/me/.local/lib/python3.8/site-packages (from camelot) (0.7.1)
Requirement already satisfied: SQLAlchemy<0.8.0,>=0.7.7 in /home/me/.local/lib/python3.8/site-packages (from camelot) (0.7.10)
Requirement already satisfied: xlrd==0.7.1 in /home/me/.local/lib/python3.8/site-packages (from camelot) (0.7.1)
Requirement already satisfied: Jinja2>=2.5.5 in /usr/lib/python3/dist-packages (from camelot) (2.10.1)
Requirement already satisfied: xlwt==0.7.2 in /home/me/.local/lib/python3.8/site-packages (from camelot) (0.7.2)
Requirement already satisfied: sqlalchemy-migrate>=0.7.1 in /home/me/.local/lib/python3.8/site-packages (from camelot) (0.11.0)
Requirement already satisfied: chardet>=1.0.1 in /usr/lib/python3/dist-packages (from camelot) (3.0.4)
Requirement already satisfied: decorator in /home/me/.local/lib/python3.8/site-packages (from sqlalchemy-migrate>=0.7.1->camelot) (5.1.0)
Requirement already satisfied: pbr>=1.8 in /home/me/.local/lib/python3.8/site-packages (from sqlalchemy-migrate>=0.7.1->camelot) (5.8.0)
Requirement already satisfied: Tempita>=0.4 in /home/me/.local/lib/python3.8/site-packages (from sqlalchemy-migrate>=0.7.1->camelot) (0.5.2)
Requirement already satisfied: six>=1.7.0 in /usr/lib/python3/dist-packages (from sqlalchemy-migrate>=0.7.1->camelot) (1.14.0)
Requirement already satisfied: sqlparse in /home/me/.local/lib/python3.8/site-packages (from sqlalchemy-migrate>=0.7.1->camelot) (0.4.2)
Attempted Solution:尝试的解决方案:
I got Ghostscript filepath output in Jupyter Notebook.我在 Jupyter Notebook 中得到了 Ghostscript 文件路径 output。
import ctypes
from ctypes.util import find_library
find_library("".join(("gsdll", str(ctypes.sizeof(ctypes.c_voidp) * 8), ".dll")))
>>> 'C:\\Users\\me\\Anaconda3\\Library\\bin\\gsdll64.dll'
Using this output, I need to "append new location to the PATH variable" .使用这个 output,我需要“将新位置附加到 PATH 变量” 。
However, this does not work still.但是,这仍然行不通。 Variations I have tried:
我尝试过的变体:
PATH=$PATH:C:\Users\me\Anaconda3\Library\bin\gsdll64.dll
PATH=$PATH:C:\\Users\\me\\Anaconda3\\Library\\bin\\gsdll64.dll
PATH=$PATH:'c/Users/me/Anaconda3/Library/bin/gsdll64.dll'
PATH=$PATH:'/mnt/c/Users/me/Anaconda3/Library/bin/gsdll64.dll'
Further, in order to get Poetry to work, I need to have PATH
point to its location:此外,为了让Poetry工作,我需要让
PATH
指向它的位置:
export PATH="$HOME/.poetry/bin:$PATH"
Can I have multiple PATH
variables?我可以有多个
PATH
变量吗?
Sometimes modules were installed in VSCode but it couldn't recognize a new module, in the left button of VSCode click on the python version and change it to another version, and after it gets back to your first python version installed the module on it.有时在 VSCode 中安装了模块但它无法识别新模块,在 VSCode 的左侧按钮中单击 python 版本并将其更改为另一个版本,然后返回到您的第一个 python 版本后在其上安装模块。 change python version for work new installed module
更改 python 版本以工作新安装的模块
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.