<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/ DTD/wml_1.1.xml">

<wml>
<head>
<meta http-equiv="cache-control" content="max-age=180,private" />
</head>
<card title="Python的虚拟环境">
<p>
作者:<a href="index.php?action=showuser&amp;userid=1&amp;hash=">admin</a><br />时间:2024-03-29 09:41<br />分类:<a href="index.php?action=list&amp;cid=3&amp;hash=">电脑技术</a><br />内容:
Python的虚拟环境


在运行pip3 install命令时候出现了下面的错误提示




XML/HTML代码


    error: externally-managed-environment  

      

    &times; This environment is externally managed  

    ╰─&gt; To install Python packages system-wide, try apt install  

        python3-xyz, where xyz is the package you are trying to  

        install.  

      

        If you wish to install a non-Debian-packaged Python package,  

        create a virtual environment using python3 -m venv path/to/venv.  

        Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make  

        sure you have python3-full installed.  

      

        If you wish to install a non-Debian packaged Python application,  

        it may be easiest to use pipx install xyz, which will manage a  

        virtual environment for you. Make sure you have pipx installed.  

      

        See /usr/share/doc/python3.11/README.venv for more information.  

      

    note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.  

    hint: See PEP 668 for the detailed specification.  




出现以上错误提示，可以在虚拟环境中解决




XML/HTML代码


    python3 -m venv .venv

    source .venv/bin/activate




然后再运行pip install或者pip3 install安装程序就可以正常进行了。
</p><p>
<a href="index.php?action=login&amp;hash=">立即登陆发表评论</a><br />
</p>
<p><a href="index.php?action=list&amp;hash=">返回日志列表</a><br /><a href="index.php?action=index&amp;hash=">返回主页</a></p>
</card>
</wml>
