为什么Python无法构建?

时间:2017-05-01 19:05:04

标签: python django heroku

我有一个在Heroku上运行的Python / Django项目,当我推动 master 分支使它自动构建时我得到了这个:

-----> Python app detected
-----> Installing requirements with pip
 $ python manage.py collectstatic --noinput
   /app/.heroku/python/lib/python2.7/site-packages/dotenv/main.py:24: UserWarning: Not loading /tmp/build_c2832b0dda7d9e04b969788b6541eb9e/BTCMedia-distributed-7754c155736b5d0a1512d1cd22cae8af4ff8451d/genesis/settings/.env - it doesn't exist.
     warnings.warn("Not loading %s - it doesn't exist." % dotenv_path)
   Traceback (most recent call last):
     File "manage.py", line 11, in <module>
       execute_from_command_line(sys.argv)
     File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
       utility.execute()
     File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
       self.fetch_command(subcommand).run_from_argv(self.argv)
     File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
       self.execute(*args, **cmd_options)
     File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
       output = self.handle(*args, **options)
     File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 193, in handle
       collected = self.collect()
     File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 115, in collect
       for path, storage in finder.list(self.ignore_patterns):
     File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/finders.py", line 112, in list
       for path in utils.get_files(storage, ignore_patterns):
     File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
       directories, files = storage.listdir(location)
     File "/app/.heroku/python/lib/python2.7/site-packages/django/core/files/storage.py", line 399, in listdir
       for entry in os.listdir(path):
   OSError: [Errno 2] No such file or directory: '/tmp/build_c2832b0dda7d9e04b969788b6541eb9e/BTCMedia-distributed-7754c155736b5d0a1512d1cd22cae8af4ff8451d/build/css'
   !     Error while running '$ python manage.py collectstatic --noinput'.
   See traceback above for details.
   You may need to update application code to resolve this error.
   Or, you can disable collectstatic for this application:
      $ heroku config:set DISABLE_COLLECTSTATIC=1
   https://devcenter.heroku.com/articles/django-assets
  !     Push rejected, failed to compile Python app.
  !     Push failed

成功的建筑看起来像这样:

   -----> Node.js app detected
   -----> Creating runtime environment

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

   Resolving node version 6.x via semver.io...
   Downloading and installing node 6.10.2...
   Using default npm version: 3.10.10
   Resolving yarn version (latest) via semver.io...
   Downloading and installing yarn (0.22.0)...
   Installed yarn 0.22.0
   -----> Restoring cache
   Loading 2 from cacheDirectories (default):
   - node_modules
   - bower_components (not cached - skipping)
   -----> Building dependencies
   Installing node modules (yarn.lock)
   yarn install v0.22.0
   [1/4] Resolving packages...
   success Already up-to-date.
   $ npm rebuild node-sass; ./node_modules/.bin/gulp build --production

   > node-sass@3.13.1 install /tmp/build_69e259837c01b4b515567a5e9cd88059/BTCMedia-distributed-98b69f6b6b5d7b9671537ca092b9bb354e890725/node_modules/node-sass
   > node scripts/install.js

   node-sass build Binary found at /tmp/build_69e259837c01b4b515567a5e9cd88059/BTCMedia-distributed-98b69f6b6b5d7b9671537ca092b9bb354e890725/node_modules/node-sass/vendor/linux-x64-48/binding.node

   > node-sass@3.13.1 postinstall /tmp/build_69e259837c01b4b515567a5e9cd88059/BTCMedia-distributed-98b69f6b6b5d7b9671537ca092b9bb354e890725/node_modules/node-sass
   > node scripts/build.js

   Binary found at /tmp/build_69e259837c01b4b515567a5e9cd88059/BTCMedia-distributed-98b69f6b6b5d7b9671537ca092b9bb354e890725/node_modules/node-sass/vendor/linux-x64-48/binding.node
   Testing binary
   Binary is fine
   node-sass@3.13.1 /tmp/build_69e259837c01b4b515567a5e9cd88059/BTCMedia-distributed-98b69f6b6b5d7b9671537ca092b9bb354e890725/node_modules/node-sass
   [16:29:48] Using gulpfile /tmp/build_69e259837c01b4b515567a5e9cd88059/BTCMedia-distributed-98b69f6b6b5d7b9671537ca092b9bb354e890725/gulpfile.js
   [16:29:48] Starting 'clean'...
   [16:29:48] Finished 'clean' after 7.71 ms
   [16:29:48] Starting 'templates'...
   [16:29:48] Finished 'templates' after 12 ms
   [16:29:48] Starting 'assets'...
   [16:29:48] Starting 'sass'...
   [16:29:48] Starting 'jsmin'...
   [16:29:48] Finished 'jsmin' after 4.09 ms
   [16:29:51] Finished 'assets' after 2.8 s
   [16:29:52] Finished 'sass' after 3.92 s
   [16:29:52] Starting 'build'...
   [16:29:52] Finished 'build' after 3.45 μs
   Done in 9.93s.
   -----> Caching build
   Clearing previous node cache
   Saving 2 cacheDirectories (default):
   - node_modules
   - bower_components (nothing to cache)
   -----> Build succeeded!
   -----> Python app detected
   -----> Installing requirements with pip
 $ python manage.py collectstatic --noinput
   /app/.heroku/python/lib/python2.7/site-packages/dotenv/main.py:24: UserWarning: Not loading /tmp/build_69e259837c01b4b515567a5e9cd88059/BTCMedia-distributed-98b69f6b6b5d7b9671537ca092b9bb354e890725/genesis/settings/.env - it doesn't exist.
     warnings.warn("Not loading %s - it doesn't exist." % dotenv_path)
   230 static files copied to '/tmp/build_69e259837c01b4b515567a5e9cd88059/BTCMedia-distributed-98b69f6b6b5d7b9671537ca092b9bb354e890725/static', 230 post-processed.
   -----> Discovering process types
   Procfile declares types -> release, web
   -----> Compressing...
   Done: 278.2M
   -----> Launching...
   !     Release command declared: this new release will not be available until the command succeeds.
   Released v129
   https://distributed-staging.herokuapp.com/ deployed to Heroku

我注意到在成功建筑中它会读取

-----> Node.js app detected

运行东西,然后

  -----> Build succeeded!
  -----> Python app detected

运行更多东西。

然而,在失败的建筑物中,它会跳过&#34;跳过&#34;直接到 -----&gt;检测到Python应用

这会给出任何线索吗? 知道问题可能是什么?

1 个答案:

答案 0 :(得分:0)

答案似乎正好在您提供的输出的底部:

https://devcenter.heroku.com/articles/django-assets

该页面将为您提供样本设置,您可以使用这些设置让collectstatic正常工作。