python - 如何自动安装和使用 conda 来启动 python 脚本?
问题描述
我有一个使用 streamlit 作为其 gui 的 python 项目。由于我即将从我的实验室毕业,因此我正努力使其尽可能易于使用,并通过自动化设置来确保它在一定程度上适应未来,以防实验室获得新的 PC 或笔记本电脑。什么是 Windows 自动化的最简单方法(作为批处理脚本、msi、exe 等)?它应该:
设置:
- 安装 anaconda/miniconda
- 从 requirements.txt 文件安装 pip 库
利用:
- 通过 miniconda/anaconda env 启动 python
streamlit run myscript.py
通过环境运行- 允许脚本访问“输入”和“输出”文件夹以读取/存储文件
我尝试了什么:
windows.bat 批处理脚本。这非常适合启动脚本,但仍需要用户找到 conda 位置并编辑批处理文件。我想尽量减少这种情况,因为我们实验室中的一些人在技术上面临很大挑战(我不得不训练多个从资源管理器地址复制粘贴位置的人)。
@ECHO OFF
:: EDIT ME ::
:: Edit the below line to point to the anaconda directory as demonstrated below ::
CALL C:\Users\albei\anaconda3\Scripts\activate.bat C:\Users\albei\anaconda3
pip install -r requirements.txt
echo ''
echo "-------------------------------------"
echo "Starting the dynamic bike script"
echo ''
echo "Keep this window open while the script is running"
echo "-------------------------------------"
:: This line just runs the streamlit script ::
streamlit run new_bike_st.py
:: Keep the terminal open ::
PAUSE
解决方案
推荐阅读
- php - 如何使用 ajax .post() 将数据传递给 php
- latex - 乳胶中的 APA6 样式 - 如何在摘要页面上隐藏标题?
- sql - 每分钟插入的记录数
- swift - 如何使用 UIDocumentPickerViewController 获取文件的完整路径?
- node.js - 为什么邮递员给我“未找到 404”错误?
- javascript - 当我点击编辑按钮时出现问题,所有其他元素都听点击,但我只需要我点击的那个
- java - 如何在maven项目中构建里面有罐子的战争
- json - Quarkus 入门(带反应式):PostGres/Docker CRUD 应用程序——缺少 POST、PUT 和 DELETE REST URL
- javascript - 每次我点击 jQuery.append 函数时,HTML 表单都会翻倍
- azure - 如何在 Azure Devops 中查看预定义变量