簡體   English   中英

如何使用 pip -t 從 git 將 package 安裝到特定目錄中

[英]How to install a package from git into a specific directory using pip -t

我已經使用AWS Linux + EFS下載了我的所有要求

pip3 install -t /mnt/efs/fs1/ml/ -r /mnt/efs/fs1/ml/requirements.txt

他們可以毫無問題地下載,我也可以給他們打電話。 現在我想安裝detectron2 ,但它必須單獨完成,因為它需要系統中已經存在的torch

我安裝它:

pip3 install -t /mnt/efs/fs1/ml/ 'git+https://github.com/facebookresearch/detectron2.git'

即使我在上述要求中安裝了torch ,並且也能夠導入它。 我也將它安裝在全局路徑中(沒有-t ),但我仍然收到錯誤:

pip3 install 'git+https://github.com/facebookresearch/detectron2.git'
Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/facebookresearch/detectron2.git
  Cloning https://github.com/facebookresearch/detectron2.git to /tmp/pip-req-build-bcthhh9q
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-bcthhh9q/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-bcthhh9q/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-nmaxo6d1
         cwd: /tmp/pip-req-build-bcthhh9q/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-bcthhh9q/setup.py", line 10, in <module>
        import torch
    ModuleNotFoundError: No module named 'torch'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

這里有什么問題? 當我不使用-t標志安裝requirements.txt時,以下命令在我的系統中完美運行。

這看起來像是版本問題,torch 和detectron2 支持的版本應該是同步的。您可以通過此go 了解詳細信息:

https://detectron2.readthedocs.io/en/latest/tutorials/install.html

找到了解決方案。 PYTHONPATH指向默認目錄,因此必須告訴env包的新位置。

您所要做的就是在終端中運行命令:

export PYTHONPATH="${PYTHONPATH}:/mnt/efs/fs1/ml"

然后像往常一樣使用命令。 它會正常工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM