Python 没有这样的文件或目录:requirements.txt
目前正在尝试运行脚本,但我被缺少的requirements.txt卡住了 这是.sh文件Python 没有这样的文件或目录:requirements.txt,python,docker,sh,Python,Docker,Sh,目前正在尝试运行脚本,但我被缺少的requirements.txt卡住了 这是.sh文件 #!/bin/bash -e # Copyright 2019 IBM All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obt
#!/bin/bash -e
# Copyright 2019 IBM All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
if [ -z "$1" ]
then
echo "Usage: ./deployCapability.sh <ACTION NAME>"
exit 1
fi
docker run --rm -v "$PWD:/tmp" ibmfunctions/action-python-v3.7 bash -c "cd /tmp && virtualenv virtualenv && source virtualenv/bin/activate && pip install -r /boxai/requirements.txt"
zip -r $1.zip virtualenv __main__.py ./src/action.py ./src/storage.py config.json ./src/bsk_utils.py ./src/__init__.py
ibmcloud fn action update $1 --kind python:3.7 $1.zip --web true --timeout 600000
date
rm $1.zip
#/bin/bash-e
#版权所有2019 IBM保留所有权利。
#
#根据Apache许可证2.0版(以下简称“许可证”)获得许可;
#除非遵守许可证,否则不得使用此文件。
#您可以通过以下方式获得许可证副本:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#除非适用法律要求或书面同意,软件
#根据许可证进行的分发是按“原样”进行分发的,
#无任何明示或暗示的保证或条件。
#请参阅许可证以了解管理权限和权限的特定语言
#许可证下的限制。
如果[-z“$1”]
然后
echo“用法:./deployCapability.sh”
出口1
fi
docker run--rm-v“$PWD:/tmp”ibmfunctions/action-python-v3.7 bash-c”cd/tmp&&virtualenv virtualenv&&source virtualenv/bin/activate&&pip install-r/boxai/requirements.txt”
zip-r$1.zip virtualenv _main __; py./src/action.py./src/storage.py config.json./src/bsk_utils.py./src/__;u init.py
ibmcloud fn操作更新$1--种类python:3.7$1.zip--web true--超时600000
日期
rm$1.zip
当我运行.sh时,我会安装setuptools、pip、wheel。。。
完成。
然后它会吐出一个错误
错误:无法打开需求文件:[Errno 2]没有这样的文件或目录:“requirements.txt”
我在哪里做错了什么
更新:我的文件夹的位置在桌面上。我还将路径更改为/boxai/requirements.txt和/c/users/admin/desktop/boxai/requirements.txt。。。。不走运
谢谢很难知道哪些文件在哪里,但是您已经使用
-v“$PWD:/tmp”
将一些文件装载到/tmp
,但是缺少的文件似乎是/boxai/requirements.txt
,它在/tmp
之外
因此,您可能需要添加-v“$PWD/requirements.txt:/boxai/requirements.txt”
,它假设您在运行shell脚本的当前目录中有一个requirements.txt
我还将路径更改为/boxai/requirements.txt
如果您从某个地方下载了此脚本,我会将其更改回以前的版本,然后将本地目录重新映射到容器中,使其与容器中预期的文件位置相对应,而不是基于主机上的路径 很难知道哪些文件在哪里,但是您已经使用
-v“$PWD:/tmp”
将一些文件装载到/tmp
,但是缺少的文件似乎是/boxai/requirements.txt
,它在/tmp
之外
因此,您可能需要添加-v“$PWD/requirements.txt:/boxai/requirements.txt”
,它假设您在运行shell脚本的当前目录中有一个requirements.txt
我还将路径更改为/boxai/requirements.txt
如果您从某个地方下载了此脚本,我会将其更改回以前的版本,然后将本地目录重新映射到容器中,使其与容器中预期的文件位置相对应,而不是基于主机上的路径 尝试
pip安装-r./boxai/requirements.txt
,您将当前文件夹映射到tmp,因此只需更改为使用相对路径,而不是尝试pip安装-r./boxai/requirements.txt
,您将当前文件夹映射到tmp,因此只需更改为使用相对路径即可