Ubuntu 22.04 LTS pipenv 未在环境中安装库

Ubuntu 22.04 LTS pipenv 未在环境中安装库

我已经通过“get-pip.py”[file][1]和apt安装了pip。还使用pip和pip3安装了“pipenv”。

但是当我使用环境创建环境时,pipenv install创建成功了,但是当我尝试安装某些库时,它使用主机 pip,并且库安装在主机路径上,而不是环境本身上。

示例:我正在安装 lib 请求,但环境路径中没有任何文件。当我尝试导入模块时,它说模块丢失。但在主机上,模块在那里。

➜  Test pipenv shell
Launching subshell in virtual environment...
➜  Test  . /home/user1/.local/share/virtualenvs/Test-f3UeTgqf/bin/activate
(Test-f3UeTgqf) ➜  Test 
(Test-f3UeTgqf) ➜  Test which pip
/home/user1/.local/bin/pip
(Test-f3UeTgqf) ➜  Test which pip3
/home/user1/.local/bin/pip3
(Test-f3UeTgqf) ➜  Test 

为什么 which 指向 pip 的主机路径,这应该是来自虚拟环境路径吗?这可能是为什么库未安装在环境中的问题吗?[1]:https://pip.pypa.io/en/stable/installation/

创建 pipenv 日志

WARNING: --three is deprecated! pipenv uses python3 by default
Creating a virtualenv for this project...
Pipfile: /home/ivan/Projects/Test/Pipfile
Using /usr/bin/python3 (3.10.6) to create virtualenv...
⠸ Creating virtual environment...created virtual environment CPython3.10.6.final.0-64 in 105ms
  creator Venv(dest=/home/ivan/.local/share/virtualenvs/Test-f3UeTgqf, clear=False, no_vcs_ignore=False, global=False, describe=CPython3Posix)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/ivan/.local/share/virtualenv)
    added seed packages: pip==22.2.2, setuptools==65.4.1, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator

✔ Successfully created virtual environment! 
Virtualenv location: /home/ivan/.local/share/virtualenvs/Test-f3UeTgqf
Creating a Pipfile for this project...
Pipfile.lock not found, creating...
Locking [packages] dependencies...
Locking [dev-packages] dependencies...
Updated Pipfile.lock (2ac81ce11198646f581b04616654f2ec6cd1f7a2c54081f2e3aecba53449386d)!
Installing dependencies from Pipfile.lock (49386d)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.

相关内容