Мой проект запускает скрипт транскрипции изображения, когда люди отправляют изображение через мой маршрут отправки.
Локально работает, используя следующий скрипт разработчика и команду pipenv run yarn dev
:
"scripts": {
"build": "tsc",
"start": "pipenv run node build/index.js",
"dev": "ts-node-dev src/index.ts",
"test": "jest --watch",
"typeorm": "ts-node ./node_modules/typeorm/cli.js -f src/ormconfig.ts",
"typeorm-dev": "ts-node ./node_modules/typeorm/cli.js -c development -f src/ormconfig.ts",
"connection": "ts-node src/util/get-connection.ts"
},
Хотя, похоже, стартовый скрипт неправильно собирает virtualenv на Heroku.
Установлены Buildpacks. Python сначала, затем Node.
В журналах выглядит так, будто он прекрасно собирается
-----> Python app detected
-----> Need to update SQLite3, clearing cache
-----> Installing python-3.7.6
-----> Installing pip
-----> Installing dependencies with Pipenv 2018.5.18…
Installing dependencies from Pipfile.lock (8b8885)…
-----> Installing SQLite3
Sqlite3 successfully installed.
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
engines.yarn (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.16.1...
Using default npm version: 6.13.4
Resolving yarn version 1.x...
Downloading and installing yarn (1.22.0)...
Installed yarn 1.22.0
-----> Restoring cache
- node_modules
-----> Installing dependencies
Installing node modules (yarn.lock)
yarn install v1.22.0
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.72s.
-----> Build
Running build (yarn)
yarn run v1.22.0
$ tsc
Done in 14.12s.
-----> Caching build
- node_modules
-----> Pruning devDependencies
yarn install v1.22.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.2: The platform "linux" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
warning Ignored scripts due to flag.
Done in 19.59s.
-----> Build succeeded!
-----> Discovering process types
Procfile declares types -> (none)
Default types for buildpack -> web
-----> Compressing...
Done: 113.9M
-----> Launching...
Released v28
https://***.herokuapp.com/ deployed to Heroku
По какой-то причине он также устанавливает SQLite. :: shrugs ::
Это мой Pipfile.
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
google-cloud-datastore = "*"
google-cloud-vision = "*"
python-decouple = "*"
python-dotenv = "*"
pyinstaller = "*"
python-datauri = "*"
[requires]
python_version = "3.7"
Вот как импортируется развязка в моем скрипте.
from sys import stdin, stdout
from json import loads, dumps
from decouple import config
from datauri import DataURI
from google.cloud import vision
from google.cloud.vision import types
# from google.oauth2 import service_account
from google.auth import compute_engine
import os
Это журнал heroku, когда я пытаюсь отправить изображение через конечную точку узла.
2020-03-03T14:00:23.367559+00:00 heroku[router]: at=info method=OPTIONS path="/submissions" host=***.herokuapp.com request_id=4cc77332-3f0f-4208-bc48-804644b7bf64 fwd="***" dyno=web.1 connect=0ms service=2ms status=204 bytes=315 protocol=https
2020-03-03T14:00:23.460776+00:00 app[web.1]: events.js:288
2020-03-03T14:00:23.460788+00:00 app[web.1]: throw er; // Unhandled 'error' event
2020-03-03T14:00:23.460788+00:00 app[web.1]: ^
2020-03-03T14:00:23.460789+00:00 app[web.1]:
2020-03-03T14:00:23.460789+00:00 app[web.1]: PythonShellError: ModuleNotFoundError: No module named 'decouple'
2020-03-03T14:00:23.460790+00:00 app[web.1]: at PythonShell.parseError (/app/node_modules/python-shell/index.js:260:21)
2020-03-03T14:00:23.460790+00:00 app[web.1]: at terminateIfNeeded (/app/node_modules/python-shell/index.js:139:32)
2020-03-03T14:00:23.460791+00:00 app[web.1]: at ChildProcess.<anonymous> (/app/node_modules/python-shell/index.js:131:13)
2020-03-03T14:00:23.460791+00:00 app[web.1]: at ChildProcess.emit (events.js:311:20)
2020-03-03T14:00:23.460791+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
2020-03-03T14:00:23.460792+00:00 app[web.1]: ----- Python Traceback -----
2020-03-03T14:00:23.460792+00:00 app[web.1]: File "src/util/scripts/transcription.py", line 3, in <module>
2020-03-03T14:00:23.460792+00:00 app[web.1]: from decouple import config
2020-03-03T14:00:23.460793+00:00 app[web.1]: Emitted 'error' event on PythonShell instance at:
2020-03-03T14:00:23.460794+00:00 app[web.1]: at terminateIfNeeded (/app/node_modules/python-shell/index.js:153:26)
2020-03-03T14:00:23.460794+00:00 app[web.1]: at ChildProcess.<anonymous> (/app/node_modules/python-shell/index.js:131:13)
2020-03-03T14:00:23.460795+00:00 app[web.1]: at ChildProcess.emit (events.js:311:20)
2020-03-03T14:00:23.460795+00:00 app[web.1]: at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12) {
2020-03-03T14:00:23.460795+00:00 app[web.1]: traceback: 'Traceback (most recent call last):\n' +
2020-03-03T14:00:23.460796+00:00 app[web.1]: ' File "src/util/scripts/transcription.py", line 3, in <module>\n' +
2020-03-03T14:00:23.460796+00:00 app[web.1]: ' from decouple import config\n' +
2020-03-03T14:00:23.460797+00:00 app[web.1]: "ModuleNotFoundError: No module named 'decouple'\n",
2020-03-03T14:00:23.460797+00:00 app[web.1]: executable: 'python3',
2020-03-03T14:00:23.460798+00:00 app[web.1]: options: null,
2020-03-03T14:00:23.460798+00:00 app[web.1]: script: 'src/util/scripts/transcription.py',
2020-03-03T14:00:23.460798+00:00 app[web.1]: args: null,
2020-03-03T14:00:23.460799+00:00 app[web.1]: exitCode: 1
2020-03-03T14:00:23.460799+00:00 app[web.1]: }
2020-03-03T14:00:23.470279+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-03-03T14:00:23.470482+00:00 app[web.1]: npm ERR! errno 1
2020-03-03T14:00:23.471369+00:00 app[web.1]: npm ERR! ***@0.0.1 start: `pipenv run node build/index.js`
2020-03-03T14:00:23.471528+00:00 app[web.1]: npm ERR! Exit status 1
2020-03-03T14:00:23.471653+00:00 app[web.1]: npm ERR!
2020-03-03T14:00:23.471736+00:00 app[web.1]: npm ERR! Failed at the ***e@0.0.1 start script.
2020-03-03T14:00:23.471813+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-03-03T14:00:23.476689+00:00 app[web.1]:
2020-03-03T14:00:23.477045+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-03-03T14:00:23.477046+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-03-03T14_00_23_472Z-debug.log
2020-03-03T14:00:23.578883+00:00 heroku[web.1]: State changed from up to crashed
2020-03-03T14:00:23.583792+00:00 heroku[web.1]: State changed from crashed to starting