无法在heroku推送应用程序

时间:2014-03-27 18:07:43

标签: git python-2.7 heroku

我正在尝试在heroku中推送应用程序。我运行以下命令 - git push heroku master

并且出现了以下错误

Initializing repository, done.
Counting objects: 3523, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3373/3373), done.
Writing objects: 100% (3523/3523), 13.96 MiB | 143 KiB/s, done.
Total 3523 (delta 348), reused 0 (delta 0)

-----> Python app detected
-----> No requirements.txt provided; assuming dist package.
-----> No runtime.txt provided; assuming python-2.7.6.
-----> Preparing Python runtime (python-2.7.6)
-----> Installing Setuptools (2.1)
-----> Installing Pip (1.5.4)
-----> Installing dependencies using Pip (1.5.4)
   Obtaining file:///app (from -r requirements.txt (line 1))
     Running setup.py (path:/app/setup.py) egg_info for package from file:///app
       Traceback (most recent call last):
         File "virtualenv.py", line 2471, in <module>
           main()
         File "virtualenv.py", line 942, in main
           never_download=options.never_download)
         File "virtualenv.py", line 1043, in create_environment
           site_packages=site_packages, clear=clear))
         File "virtualenv.py", line 1205, in install_python
           copyfile(join(stdlib_dir, fn), join(lib_dir, fn))
         File "virtualenv.py", line 433, in copyfile
           copyfileordir(src, dest)
         File "virtualenv.py", line 408, in copyfileordir
           shutil.copytree(src, dest, True)
         File "/app/.heroku/python/lib/python2.7/shutil.py", line 177, in copytree
           os.makedirs(dst)
         File "/app/.heroku/python/lib/python2.7/os.py", line 157, in makedirs
           mkdir(name, mode)
       OSError: [Errno 17] File exists: 'flask/lib/python2.7/config'
       Traceback (most recent call last):
         File "<string>", line 17, in <module>
         File "/app/setup.py", line 8, in <module>
           subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask<0.10'])
         File "/app/.heroku/python/lib/python2.7/subprocess.py", line 522, in call
           return Popen(*popenargs, **kwargs).wait()
         File "/app/.heroku/python/lib/python2.7/subprocess.py", line 709, in __init__
           errread, errwrite)
         File "/app/.heroku/python/lib/python2.7/subprocess.py", line 1326, in _execute_child
           raise child_exception
       OSError: [Errno 2] No such file or directory
       Complete output from command python setup.py egg_info:
       Traceback (most recent call last):

     File "virtualenv.py", line 2471, in <module>

       main()

     File "virtualenv.py", line 942, in main

       never_download=options.never_download)

     File "virtualenv.py", line 1043, in create_environment

       site_packages=site_packages, clear=clear))

     File "virtualenv.py", line 1205, in install_python

       copyfile(join(stdlib_dir, fn), join(lib_dir, fn))

     File "virtualenv.py", line 433, in copyfile

       copyfileordir(src, dest)

     File "virtualenv.py", line 408, in copyfileordir

       shutil.copytree(src, dest, True)

     File "/app/.heroku/python/lib/python2.7/shutil.py", line 177, in copytree

       os.makedirs(dst)

     File "/app/.heroku/python/lib/python2.7/os.py", line 157, in makedirs

       mkdir(name, mode)

   OSError: [Errno 17] File exists: 'flask/lib/python2.7/config'

   Traceback (most recent call last):

     File "<string>", line 17, in <module>

     File "/app/setup.py", line 8, in <module>

       subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask<0.10'])

     File "/app/.heroku/python/lib/python2.7/subprocess.py", line 522, in call

       return Popen(*popenargs, **kwargs).wait()

     File "/app/.heroku/python/lib/python2.7/subprocess.py", line 709, in __init__

       errread, errwrite)

     File "/app/.heroku/python/lib/python2.7/subprocess.py", line 1326, in _execute_child

       raise child_exception

   OSError: [Errno 2] No such file or directory

   ----------------------------------------
   Cleaning up...
   Command python setup.py egg_info failed with error code 1 in /app
   Storing debug log for failure in /app/.pip/pip.log

这个堆栈跟踪说没有提供requirements.txt;假设dist包,但我已经在应用程序根目录中有requirements.txt。

我的pip.log文件看起来像

Command python setup.py egg_info failed with error code 1
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 126, in main
    self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 223, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle,     

bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 980, in prepare_files
    req_to_install.run_egg_info()
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 216, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 255, in call_subprocess
    % (command_desc, proc.returncode))
InstallationError: Command python setup.py egg_info failed with error code 1

我的setup.py看起来像这样

!/usr/bin/python
import os, subprocess, sys
subprocess.call(['python', 'virtualenv.py', 'flask'])
if sys.platform == 'win32':
bin = 'Scripts'
else:
    bin = 'bin'
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask<0.10'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask-login'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask-openid'])
if sys.platform == 'win32':
    subprocess.call([os.path.join('flask', bin, 'pip'), 'install', '--no-deps',     
'lamson', 'chardet', 'flask-mail'])
else:
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask-mail'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'sqlalchemy==0.7.9'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask-sqlalchemy'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'sqlalchemy-migrate'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask-whooshalchemy'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask-wtf'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flask-babel'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'guess-language'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'flup'])
subprocess.call([os.path.join('flask', bin, 'pip'), 'install', 'coverage'])

在推送heroku时不确定此脚本是否无效。它在我的本地机器上运行良好。

我的requirements.txt是

Babel==1.3
Flask==0.10.1
Flask-Babel==0.9
Flask-Login==0.2.10
Flask-Mail==0.9.0
Flask-OpenID==1.2.1
Flask-SQLAlchemy==1.0
Flask-WTF==0.9.4
Flask-WhooshAlchemy==0.55a
Jinja2==2.7.2
MarkupSafe==0.19
SQLAlchemy==0.9.4
Tempita==0.5.2
WTForms==1.0.5
Werkzeug==0.9.4
Whoosh==2.6.0
argparse==1.2.1
blinker==1.3
decorator==3.4.0
flup==1.0.2
gunicorn==18.0
itsdangerous==0.23
pbr==0.8.0
psycopg2==2.5.2
python-openid==2.2.5
pytz==2014.1
six==1.6.1
speaklater==1.3
sqlalchemy-migrate==0.9
wsgiref==0.1.2

1 个答案:

答案 0 :(得分:0)

由于您在代码中进行的子进程调用,您的部署失败了。 Heroku上不存在您尝试运行的路径。

您可能希望删除这些调用,或者以可以正常工作的方式重写它。