簡體   English   中英

導入 Python API 時 node.js 中出現“找不到模塊”錯誤

[英]"Module not found" error in node.js while importing Python API

我正在創建一個 React 應用程序並按照說明使用此 API 實現流行時間數據: https : //github.com/m-wrzr/populartimes

根據指示,我能夠成功克隆和 pip 安裝存儲庫要求。 但是,當我嘗試使用以下代碼行運行文件時:

import React, { Component } from 'react';
import firebase from 'firebase/app';
import populartimes from './populartimes/populartimes/';

我收到“找不到模塊”錯誤。 對於上下文,populartimes 文件夾與我們正在處理的文件位於同一目錄中。 此外,populartimes/populartimes/ 包含兩個 python 文件( init和 crawler)

你不能直接在 JavaScript 中使用 Python 代碼/庫。 要實現此 API,請執行以下任一操作:

  1. 使用此 API 的 JS 庫。 快速 Google 搜索為我提供了這個庫@christophern/populartimesjs

  2. 實現一個 python 后端並在那里使用你想要的 python 庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM