2016-03-22 12 views
2

Bir köstebek çalışıyor, ancak bir sunucuya veya yeni bir Heroku örneğine ihtiyaç duymayan küçük bir Python modülü var. Ama pip'ten 3. parti paketler kurması gerekiyor.Polehon modülü ile projede Python modülünde Node uygulaması yüklenmiyor

Sorunum, Python'un düzgün çalıştığı (bir print() .py dosyasında mükemmel çalışıyor) modülleri yüklememesidir. pip freeze'u çalıştırdım ve requirements.txt dosyasını projemin köküne ekledim. dosya:

funcy==1.6 
numpy==1.10.2 
scipy==0.16.1 

Ama hiç piton algılamaz Heroku dağıtmak ve onları yüklemek gibi görünmüyor ve ben aldığımda:

Traceback (most recent call last): File "src/blm/algo.py", line 4, in <module> from package import mvo File "/app/src/blm/package/mvo.py", line 1, in <module> import numpy as np ImportError: No module named 'numpy' 

Heroku

çıktısı
-----> Using set buildpack heroku/nodejs 
-----> Node.js app detected 
-----> Creating runtime environment 

     NPM_CONFIG_LOGLEVEL=error 
     NPM_CONFIG_PRODUCTION=true 
     NODE_ENV=production 
     NODE_MODULES_CACHE=true 
-----> Installing binaries 
     engines.node (package.json): unspecified 
     engines.npm (package.json): unspecified (use default) 

     Resolving node version (latest stable) via semver.io... 
     Downloading and installing node 5.8.0... 
     Using default npm version: 3.7.3 
-----> Restoring cache 
     Loading 2 from cacheDirectories (default): 
     - node_modules 
     - bower_components (not cached - skipping) 
-----> Building dependencies 
     Pruning any extraneous modules 
     Installing node modules (package.json) 

     > [email protected] postinstall /tmp/build_c845357a6a491eb02f8ad4b043020ac6/my-project-7f7e7fe8632473e1f1f88f430b040396fb10671f 
     > webpack --config ./webpack-production.config.js --progress --colors 

Hash: 2ceaeac5876ff2e2463e 
     Version: webpack 1.12.14 
     Time: 15178ms 
     Asset Size Chunks    Chunk Names 
     bundle.js 455 kB  0 [emitted] main 
     main.css 15 kB  0 [emitted] main 
     + 272 hidden modules 
     Child extract-text-webpack-plugin: 
     + 2 hidden modules 
-----> Caching build 
     Clearing previous node cache 
     Saving 2 cacheDirectories (default): 
     - node_modules 
     - bower_components (nothing to cache) 
-----> Build succeeded! 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     ├── [email protected] 
     └── [email protected] 

-----> Discovering process types 
     Procfile declares types -> web 
-----> Compressing... 
     Done: 30M 
-----> Launching... 
     Released v13 
     https://my-project.herokuapp.com/ deployed to Heroku 

=== GÜNCELLEME ===

yüklemek olsaydı ben de görmek için bir "pipinstall" işçi ekleyerek çalıştı

ama hiçbir şey ha ppened.

Procfile:

web: node server.js 
pipinstall: pip install -r requirements.txt 

cevap

2

Uygulamanız buildpacksfor birden gerekir.

çalıştırın aşağıdaki:

Heroku yapılandırma: BUILDPACK_URL = https://github.com/ddollar/heroku-buildpack-multi Sonra

, bir dosyaya aşağıdakileri ekleyin set projenizin kök dizininde denilen .buildpacks:

https://github.com/heroku/heroku-buildpack-python.git 
https://github.com/heroku/heroku-buildpack-nodejs.git 

Alternatif seni here açıklandığı gibi, çoklu buildpack'lerinizi yapılandırmak için heroku toolbelt komutlarını (heroku buildpacks: set ve heroku buildpacks: add) kullanabilirsiniz.

+0

Ben böyle yaptım, ancak kayıt için, SciPy (hangi yüklemeye çalışıyordu) resmi olarak [Heroku'nun Python kılavuzunun bu sayfasına] göre desteklenmiyor (https://devcenter.heroku.com/ yazılar/piton-c-deps). Bir [geçici çözüm] (https://github.com/thenovices/heroku-buildpack-scipy) var gibi görünüyor, ancak sadece Düğüm ve Python buildpacks kullanımı dyno bellek sınırını zorluyor. –