简体   繁体   English

在 VScode 开发容器的文件夹内安装 requirements.txt

[英]Installing requirements.txt inside of a folder in a VScode dev container

I am using Microsoft's template for Python dev-container https://github.com/microsoft/vscode-remote-try-python我正在使用 Microsoft 的 Python 开发容器模板https://github.com/microsoft/vscode-remote-try-python

and it worked as it should, I made a small change to the structure.它正常工作,我对结构进行了一些小改动。 I added a folder called "project1" and moved the requirements.txt file to that folder.我添加了一个名为“project1”的文件夹并将 requirements.txt 文件移动到该文件夹​​中。

When I update the .devcontainer file with this setting:当我使用此设置更新 .devcontainer 文件时:

{
...
"postCreateCommand": "pip install -r subject-selection/requirements.txt"
...
}

It fails, saying it cannot find the file.它失败了,说它找不到文件。 What am I doing wrong?我究竟做错了什么?

This is the file structure:这是文件结构:

.
├── Dockerfile
├── README.md
├── data
└── subject-selection
    ├── Dataset Analysis.ipynb
    ├── __pycache__
    │   └── analysis_utils.cpython-39.pyc
    ├── analysis_utils.py
    ├── download-subjects.py
    ├── out
    ├── requirements.txt
    └── run-placement-analysis.sh

I believe that postCreateCommand runs from the location /bin/sh , so in your case it's looking for the file '/bin/sh/subject-selection/requirements.txt'.我相信postCreateCommand从位置/bin/sh ,所以在你的情况下它正在寻找文件'/bin/sh/subject-selection/requirements.txt'。 You probably want something like this instead:你可能想要这样的东西:

"postCreateCommand": "pip install -r /workspaces/subject-selection/requirements.txt"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM