本文主要是介绍手动安装environment.yml的依赖包,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在使用environment.yml
文件来管理项目依赖的时候,通常我们会使用Anaconda或Miniconda创建一个环境,这样可以确保所有必需的Python包和特定版本都正确安装。下面是如何手动安装environment.yml
中定义的依赖包的步骤:
1. 创建一个新的conda环境
首先,你需要有一个名为environment.yml
的文件,其中列出了你的所有依赖项及其版本信息。这个文件看起来可能像这样:
name: myprojectenv
dependencies:- python=3.7- numpy- pandas- scipy- pip:- some-python-package # 使用pip安装的包
要创建一个新环境并安装所有的依赖项,你可以在命令行中运行以下命令:
conda env create -f environment.yml
这将根据environment.yml
文件创建一个名为myprojectenv
的新环境。
2. 激活新环境
创建完环境后,需要激活它才能开始使用:
-
在Windows上:
conda activate myprojectenv
-
在Unix或MacOS上:
source activate myprojectenv
或者,在较新的Anaconda版本中,你可以使用conda activate myprojectenv
在所有平台上。
3. 手动添加额外的依赖(如果需要)
如果你需要手动添加依赖,可以使用conda install
或pip install
来安装额外的包。例如:
conda install package_name
pip install another_package
4. 查看已安装的包
你可以通过以下命令查看环境中已经安装了哪些包:
conda list
这将显示当前激活环境中的所有包以及它们的版本。
5. 更新环境文件
如果你手动添加了新的依赖项,你应该更新environment.yml
文件以包含这些新的依赖项,这样其他人可以根据最新的文件重建相同的环境。
6. 删除环境(可选)
当你不再需要某个环境时,可以删除它:
conda env remove -n myprojectenv
以上就是如何使用environment.yml
文件来管理你的Python项目的依赖关系。这种方式有助于确保你的项目能够在不同的机器上一致地运行。
7.实际运行
Ran pip subprocess with arguments:
['E:\\Anaconda\\envs\\nudd-env-offical\\python.exe', '-m', 'pip', 'install', '-U', '-r', 'E:\\RomulusHe\\Projects\\NUDD\\DjangoProDemo-followup\\condaenv.gvwkf7xc.requirements.txt']
Pip subprocess output:
Collecting amqp==5.2.0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 1))Using cached amqp-5.2.0-py3-none-any.whl.metadata (8.9 kB)
Collecting apscheduler==3.10.4 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 2))Using cached APScheduler-3.10.4-py3-none-any.whl.metadata (5.7 kB)
Collecting asgiref==3.8.1 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 3))Using cached asgiref-3.8.1-py3-none-any.whl.metadata (9.3 kB)
Collecting async-timeout==4.0.3 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 4))Using cached async_timeout-4.0.3-py3-none-any.whl.metadata (4.2 kB)
Collecting billiard==4.2.0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 5))Using cached billiard-4.2.0-py3-none-any.whl.metadata (4.4 kB)
Collecting celery==5.4.0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 6))Using cached celery-5.4.0-py3-none-any.whl.metadata (21 kB)
Collecting certifi==2024.8.30 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 7))Using cached certifi-2024.8.30-py3-none-any.whl.metadata (2.2 kB)
Collecting charset-normalizer==3.3.2 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 8))Using cached charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl.metadata (34 kB)
Collecting click==8.1.7 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 9))Using cached click-8.1.7-py3-none-any.whl.metadata (3.0 kB)
Collecting click-didyoumean==0.3.1 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 10))Using cached click_didyoumean-0.3.1-py3-none-any.whl.metadata (3.9 kB)
Collecting click-plugins==1.1.1 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 11))Using cached click_plugins-1.1.1-py2.py3-none-any.whl.metadata (6.4 kB)
Collecting click-repl==0.3.0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 12))Using cached click_repl-0.3.0-py3-none-any.whl.metadata (3.6 kB)
Collecting colorama==0.4.6 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 13))Using cached colorama-0.4.6-py2.py3-none-any.whl.metadata (17 kB)
Collecting django==5.1 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 14))Using cached Django-5.1-py3-none-any.whl.metadata (4.2 kB)
Collecting django-apscheduler==0.6.2 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 15))Using cached django_apscheduler-0.6.2-py3-none-any.whl.metadata (15 kB)
Collecting et-xmlfile==1.1.0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 16))Using cached et_xmlfile-1.1.0-py3-none-any.whl.metadata (1.8 kB)
Collecting idna==3.8 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 17))Using cached idna-3.8-py3-none-any.whl.metadata (9.9 kB)
Collecting kombu==5.4.0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 18))Using cached kombu-5.4.0-py3-none-any.whl.metadata (3.1 kB)
Collecting mysqlclient==2.2.4 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 19))Using cached mysqlclient-2.2.4-cp310-cp310-win_amd64.whl.metadata (4.6 kB)
Collecting numpy==2.1.0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 20))Using cached numpy-2.1.0-cp310-cp310-win_amd64.whl.metadata (59 kB)
Collecting openpyxl==3.1.5 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 21))Using cached openpyxl-3.1.5-py2.py3-none-any.whl.metadata (2.5 kB)
Collecting pandas==2.2.2 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 22))Using cached pandas-2.2.2-cp310-cp310-win_amd64.whl.metadata (19 kB)
Collecting pika==1.3.2 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 23))Using cached pika-1.3.2-py3-none-any.whl.metadata (13 kB)
Collecting prompt-toolkit==3.0.47 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 24))Using cached prompt_toolkit-3.0.47-py3-none-any.whl.metadata (6.4 kB)
Collecting psycopg2-binary==2.9.9 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 25))Using cached psycopg2_binary-2.9.9-cp310-cp310-win_amd64.whl.metadata (4.6 kB)
Collecting pymysql==1.1.1 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 26))Using cached PyMySQL-1.1.1-py3-none-any.whl.metadata (4.4 kB)
Collecting python-dateutil==2.9.0.post0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 27))Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
Collecting pytz==2024.1 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 28))Using cached pytz-2024.1-py2.py3-none-any.whl.metadata (22 kB)
Collecting redis==5.0.8 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 29))Using cached redis-5.0.8-py3-none-any.whl.metadata (9.2 kB)
Collecting requests==2.32.3 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 30))Using cached requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
Collecting six==1.16.0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 31))Using cached six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Collecting sqlparse==0.5.1 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 32))Using cached sqlparse-0.5.1-py3-none-any.whl.metadata (3.9 kB)
Collecting typing-extensions==4.12.2 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 33))Using cached typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB)
Collecting tzdata==2024.1 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 34))Using cached tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB)
Collecting tzlocal==5.2 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 35))Using cached tzlocal-5.2-py3-none-any.whl.metadata (7.8 kB)
Collecting urllib3==2.2.2 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 36))Using cached urllib3-2.2.2-py3-none-any.whl.metadata (6.4 kB)
Collecting vine==5.1.0 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 37))Using cached vine-5.1.0-py3-none-any.whl.metadata (2.7 kB)
Collecting wcwidth==0.2.13 (from -r E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup\condaenv.gvwkf7xc.requirements.txt (line 38))Using cached wcwidth-0.2.13-py2.py3-none-any.whl.metadata (14 kB)
Using cached amqp-5.2.0-py3-none-any.whl (50 kB)
Using cached APScheduler-3.10.4-py3-none-any.whl (59 kB)
Using cached asgiref-3.8.1-py3-none-any.whl (23 kB)
Using cached async_timeout-4.0.3-py3-none-any.whl (5.7 kB)
Using cached billiard-4.2.0-py3-none-any.whl (86 kB)
Using cached celery-5.4.0-py3-none-any.whl (425 kB)
Using cached certifi-2024.8.30-py3-none-any.whl (167 kB)
Using cached charset_normalizer-3.3.2-cp310-cp310-win_amd64.whl (100 kB)
Using cached click-8.1.7-py3-none-any.whl (97 kB)
Using cached click_didyoumean-0.3.1-py3-none-any.whl (3.6 kB)
Using cached click_plugins-1.1.1-py2.py3-none-any.whl (7.5 kB)
Using cached click_repl-0.3.0-py3-none-any.whl (10 kB)
Using cached colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Using cached Django-5.1-py3-none-any.whl (8.2 MB)
Using cached django_apscheduler-0.6.2-py3-none-any.whl (24 kB)
Using cached et_xmlfile-1.1.0-py3-none-any.whl (4.7 kB)
Using cached idna-3.8-py3-none-any.whl (66 kB)
Using cached kombu-5.4.0-py3-none-any.whl (200 kB)
Using cached mysqlclient-2.2.4-cp310-cp310-win_amd64.whl (203 kB)
Using cached numpy-2.1.0-cp310-cp310-win_amd64.whl (12.9 MB)
Using cached openpyxl-3.1.5-py2.py3-none-any.whl (250 kB)
Using cached pandas-2.2.2-cp310-cp310-win_amd64.whl (11.6 MB)
Using cached pika-1.3.2-py3-none-any.whl (155 kB)
Using cached prompt_toolkit-3.0.47-py3-none-any.whl (386 kB)
Using cached psycopg2_binary-2.9.9-cp310-cp310-win_amd64.whl (1.2 MB)
Using cached PyMySQL-1.1.1-py3-none-any.whl (44 kB)
Using cached python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
Using cached pytz-2024.1-py2.py3-none-any.whl (505 kB)
Using cached redis-5.0.8-py3-none-any.whl (255 kB)
Using cached requests-2.32.3-py3-none-any.whl (64 kB)
Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Using cached sqlparse-0.5.1-py3-none-any.whl (44 kB)
Using cached typing_extensions-4.12.2-py3-none-any.whl (37 kB)
Using cached tzdata-2024.1-py2.py3-none-any.whl (345 kB)
Using cached tzlocal-5.2-py3-none-any.whl (17 kB)
Using cached urllib3-2.2.2-py3-none-any.whl (121 kB)
Using cached vine-5.1.0-py3-none-any.whl (9.6 kB)
Using cached wcwidth-0.2.13-py2.py3-none-any.whl (34 kB)
Installing collected packages: wcwidth, pytz, vine, urllib3, tzdata, typing-extensions, sqlparse, six, pymysql, psycopg2-binary, prompt-toolkit, pika, numpy, mysqlclient, idna, et-xmlfile, colorama, charset-normalizer, certifi, billiard, async-timeout, tzlocal, requests, redis, python-dateutil, openpyxl, click, asgiref, amqp, pandas, kombu, django, click-repl, click-plugins, click-didyoumean, apscheduler, django-apscheduler, celery
Successfully installed amqp-5.2.0 apscheduler-3.10.4 asgiref-3.8.1 async-timeout-4.0.3 billiard-4.2.0 celery-5.4.0 certifi-2024.8.30 charset-normalizer-3.3.2 click-8.1.7 click-didyoumean-0.3.1 click-plugins-1.1.1 click-repl-0.3.0 colorama-0.4.6 django-5.1 django-apscheduler-0.6.2 et-xmlfile-1.1.0 idna-3.8 kombu-5.4.0 mysqlclient-2.2.4 numpy-2.1.0 openpyxl-3.1.5 pandas-2.2.2 pika-1.3.2 prompt-toolkit-3.0.47 psycopg2-binary-2.9.9 pymysql-1.1.1 python-dateutil-2.9.0.post0 pytz-2024.1 redis-5.0.8 requests-2.32.3 six-1.16.0 sqlparse-0.5.1 typing-extensions-4.12.2 tzdata-2024.1 tzlocal-5.2 urllib3-2.2.2 vine-5.1.0 wcwidth-0.2.13done
#
# To activate this environment, use
#
# $ conda activate nudd-env-offical
#
# To deactivate an active environment, use
#
# $ conda deactivatePS E:\RomulusHe\Projects\NUDD\DjangoProDemo-followup>
这篇关于手动安装environment.yml的依赖包的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!