github克隆别人的项目并创建环境安装子模块 - 教程
<style>pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco", "Courier New", monospace !important; font-size: 14px !important; line-height: 1.6 !important; padding: 16px !important; margin: 16px 0 !important; background-color: rgba(248, 248, 248, 1) !important; border: 1px solid rgba(225, 228, 232, 1) !important; border-radius: 6px !important; tab-size: 4 !important; -moz-tab-size: 4 !important; max-width: 100% !important; box-sizing: border-box !important }code { font-family: "Consolas", "Monaco", "Courier New", monospace !important; font-size: 14px !important; white-space: pre !important; word-wrap: normal !important; word-break: normal !important; overflow-wrap: normal !important; display: inline !important; background: rgba(0, 0, 0, 0) !important; border: none !important; padding: 0 !important; margin: 0 !important; line-height: inherit !important }
pre code { background: rgba(0, 0, 0, 0) !important; border: 0 !important; border-radius: 0 !important; display: block !important; line-height: 1.6 !important; margin: 0 !important; max-width: none !important; overflow: visible !important; padding: 0 !important; white-space: pre !important; word-wrap: normal !important; word-break: normal !important; color: inherit !important }
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: rgba(112, 128, 144, 1) !important; font-style: italic !important }
.token.punctuation { color: rgba(153, 153, 153, 1) !important }
.token.atrule, .token.attr-value, .token.keyword { color: rgba(0, 119, 170, 1) !important; font-weight: bold !important }
.token.function, .token.class-name { color: rgba(221, 74, 104, 1) !important; font-weight: bold !important }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: rgba(102, 153, 0, 1) !important }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: rgba(153, 0, 85, 1) !important }
.cnblogs-markdown pre, .cnblogs-post-body pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; background-color: rgba(248, 248, 248, 1) !important; border: 1px solid rgba(225, 228, 232, 1) !important; border-radius: 6px !important; padding: 16px !important; margin: 16px 0 !important }
pre, pre, pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important }</style>
<div class="htmledit_views atom-one-dark" id="content_views"><p> 下面梳理一下一般克隆别人的项目并且创建环境,安装子模块的流程</p><h2>1.先克隆别人的代码</h2>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code class="hljs">git clone 地址(通过github Code里面HTTPS里面得到地址)</code></pre>
<h2><strong>2.要进入你克隆的项目的目录</strong></h2><p><img alt="" height="44" src="https://i-blog.csdnimg.cn/direct/e68b9909c26e43c7a8f342b129d82cbf.png" width="1303"></p><h2>3.使用conda创建环境</h2><p>(<strong>记住把env_name换成你自己命名的环境名字。python=3.12换成自己的python版本号码</strong>)</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code class="hljs">conda create -n env_name python=3.12</code></pre>
<p>激活你创建的环境(<strong>把env_name换成你创建的环境名字</strong>)</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code class="hljs">conda activate env_name</code></pre>
<p>如果想要跳出原来的环境可以用下面的代码</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code class="hljs">conda deactivate</code></pre>
<h2>4. 安装项目环境的依赖</h2>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code class="hljs">pip install -r requirements.txt
pip install -e .</code></pre>
<p>如果某些包安装失败可能是源不行,换成清华源(如果下面每一步都安装失败都可以加入清华源,也可以直接替换conda的源一劳永逸)</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code class="hljs">pip install -r requirements.txt -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple</code></pre>
<h2>5. 如果有子模块要安装子模块</h2><p>(子模块其实也就是作者写的要用到的函数文件)</p><p>比如下面要安装两个子模块various_tools和dynamic_obstacle_avoidance</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code class="hljs">pip install "git+https://github.com/hubernikus/various_tools.git"
pip install "git+https://github.com/hubernikus/dynamic_obstacle_avoidance.git"</code></pre>
<p>但有时候连不上github,子模块安装失败,可以直接下载zip文件,然后解压,把解压后的文件放到你整个项目的文件夹里面,相当于是作为项目的函数</p><p>如果是自己解压的话,那安装子模块的命令就变成下面的(注意要把命令里面的文件名字various_tools和dynamic_obstacle_avoidance换成自己的子模块文件名字)</p>
<pre style="white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important"><code class="hljs"># 安装本地的 various_tools
pip install -e ./various_tools
# 安装本地的 dynamic_obstacle_avoidance
pip install -e ./dynamic_obstacle_avoidance</code></pre>
<p></p></div><br><br>
来源:https://www.cnblogs.com/tlnshuju/p/19163892
頁:
[1]