簡體   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