错误:由于环境错误而无法安装软件包:[Errno 2]没有这样的文件或目录:'/ C:/ ci / astroid_1592481955828 / work'

时间:2020-07-07 08:02:17

标签: python heroku

我正在尝试将一个python项目推送到Heroku,并且每次运行git push heroku master时都会出现此错误

$ git push heroku master
Enumerating objects: 19, done.
Counting objects: 100% (19/19), done.
Delta compression using up to 4 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (19/19), 4.27 KiB | 728.00 KiB/s, done.
Total 19 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.6.10
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:        Processing /C:/ci/astroid_1592481955828/work
remote:        ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/C:/ci/astroid_1592481955828/work'
remote:
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to flask-plan-app.
remote:
To https://git.heroku.com/flask-plan-app.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/flask-plan-app.git'

我也曾尝试在笔记本电脑上查找丢失的文件,但我无法,请问如何解决此问题?

这是我的required.txt文件

astroid @ file:C:/ci/astroid_1592481955828/work
certifi==2020.6.20
click==7.1.2
colorama==0.4.3
Flask==1.1.2
Flask-SQLAlchemy==2.4.3
gunicorn==20.0.4
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.11.2
lazy-object-proxy==1.4.3
MarkupSafe==1.1.1
mccabe==0.6.1
pylint @ file:///C:/ci/pylint_1592487534522/work
six==1.15.0
SQLAlchemy==1.3.18
toml @ file:///tmp/build/80754af9/toml_1592853716807/work
typed-ast==1.4.1
Werkzeug==1.0.1
wincertstore==0.2
wrapt==1.11.2

2 个答案:

答案 0 :(得分:1)

我是初学者,所以请带一点盐。

我删除了需求文件中的所有“ @路径”后缀,只留下了软件包名称,这阻止了此错误的发生。

所以:

astroid 
certifi==2020.6.20
click==7.1.2
colorama==0.4.3
Flask==1.1.2
Flask-SQLAlchemy==2.4.3
gunicorn==20.0.4
isort==4.3.21
itsdangerous==1.1.0
Jinja2==2.11.2
lazy-object-proxy==1.4.3
MarkupSafe==1.1.1
mccabe==0.6.1
pylint 
six==1.15.0
SQLAlchemy==1.3.18
toml 
typed-ast==1.4.1
Werkzeug==1.0.1
wincertstore==0.2
wrapt==1.11.2

答案 1 :(得分:0)

嗨,我刚遇到这个问题并能够解决。以防将来任何人遇到相同问题时发帖。

按照@extracheez的说明删除多余的@路径。然后确保您提交并在之后推送到Git。那为我解决了。

git add -A
git commit -m "removed surplus @ paths in requirements.txt file"
git push -u origin master

不过可能会弹出另一个错误,例如FileNotFoundError: [Errno 2] No such file or directory: '/tmp/build_51de3815/static'

要解决此问题,请在您的静态文件夹中创建一个.temporary_file文件。与Git无法跟踪空目录有关,因此,它在Heroku中不存在。

touch static/.keep