【问题标题】:not able to run pip in python3 venv无法在 python3 venv 中运行 pip
【发布时间】:2023-01-11 13:02:01
【问题描述】:

我使用以下命令创建了 python 虚拟环境

python3 -m venv env

但是我无法在其中运行 pip 来安装依赖项,有人可以帮忙吗, 虽然我可以看到 bin 中存在 pip

(env) u@u-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ ls -lart
    total 44
    drwxrwxr-x 5 s s 4096 Jan 11 08:49 ..
    lrwxrwxrwx 1 s s    7 Jan 11 08:49 python3.10 -> python3
    lrwxrwxrwx 1 s s   16 Jan 11 08:49 python3 -> /usr/bin/python3
    lrwxrwxrwx 1 s s    7 Jan 11 08:49 python -> python3
    -rwxrwxr-x 1 s s  284 Jan 11 08:50 pip3.10
    -rwxrwxr-x 1 s s  284 Jan 11 08:50 pip3
    -rwxrwxr-x 1 s s  284 Jan 11 08:50 pip
    -rw-r--r-- 1 s s 9033 Jan 11 08:50 Activate.ps1
    -rw-r--r-- 1 s s 2100 Jan 11 08:50 activate.fish
    -rw-r--r-- 1 s s  958 Jan 11 08:50 activate.csh
    -rw-r--r-- 1 s s 2032 Jan 11 08:50 activate
    drwxrwxr-x 2 s s 4096 Jan 11 08:50 .
    (env) s@s-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ python3 -m pip install -r requirements.txt
    /home/s/Documents/github/CarPartsDetectionChallenge_v3p/env/bin/python3: No module named pip
    (env) s@s-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ pip install tensorflow
    Traceback (most recent call last):
      File "/home/s/Documents/github/CarPartsDetectionChallenge_v3p/env/bin/pip", line 5, in <module>
        from pip._internal.cli.main import main
    ModuleNotFoundError: No module named 'pip'
    (env) s@s-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ python3 --version
    Python 3.7.16

【问题讨论】:

    标签: python-3.x pip python-venv pyvenv


    【解决方案1】:

    试试python3 -m pip3 install -r requirements.txt

    如果没有找到 pip3,看来你需要安装 pip/pip3。

    【讨论】:

      【解决方案2】:

      将你的 python 与 pip 包管理器链接起来:

      激活虚拟环境后运行以下命令。

      对于 Windows:

      python3 -m ensurepip
      

      对于 Linux:

      sudo apt-get install python3-pip
      

      【讨论】:

        猜你喜欢
        • 2021-07-30
        • 2020-10-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多