繁体   English   中英

ModuleNotFoundError:没有名为“camelot”的模块 | 适用于 Jupyter Notebooks 但不适用于 VSCode

[英]ModuleNotFoundError: No module named 'camelot' | Works in Jupyter Notebooks but not VSCode

目标:通过PDF获得本教程的工作版本。 视觉工作室代码。

我正在尝试通过安装camelot VSCode ,使用诗歌,但有依赖问题。

这适用于Jupyter Notebooks (帖子底部),但我正在尝试将 append 转换为 existing.py 项目。

代码:

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

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)

尝试的解决方案:

我在 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'

使用这个 output,我需要“将新位置附加到 PATH 变量”

但是,这仍然行不通。 我尝试过的变体:

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'

此外,为了让Poetry工作,我需要让PATH指向它的位置:

export PATH="$HOME/.poetry/bin:$PATH"

我可以有多个PATH变量吗?

有时在 VSCode 中安装了模块但它无法识别新模块,在 VSCode 的左侧按钮中单击 python 版本并将其更改为另一个版本,然后返回到您的第一个 python 版本后在其上安装模块。 更改 python 版本以工作新安装的模块

暂无
暂无

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

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