简体   繁体   English

Python-自动安装依赖项

[英]Python - automatically installing dependencies

I am hoping to use Python to write a script that will automate the change control ticket creation process at the organization I am consulting at. 我希望使用Python编写一个脚本,该脚本将在我所咨询的组织中自动执行变更控制票证的创建过程。 The users should be able to double click a file (or worst case, just run the script from the terminal) and have it do its thing. 用户应该能够双击一个文件(或者在最坏的情况下,只需从终端运行脚本)并执行该操作即可。 In other words, the only thing I want them to have to install is Python. 换句话说,我希望他们必须安装的唯一东西是Python。

However, the script is likely to make use of a couple other resources, including Selenium. 但是,该脚本很可能会利用其他一些资源,包括Selenium。 Is there a way that when the analysts run the script, it can check if Selenium and any other dependencies are installed and install them if not? 有没有一种方法可以让分析师在运行脚本时检查Selenium和其他依赖项是否已安装,如果没有安装,则可以进行安装? Something like NPM does? 像NPM一样吗?

A bonus Selenium-related question if anybody wants to step forward -- how do you check if the user is logged in to a specific website given that the access token the users will have received is browser specific and Selenium will be operating a headless browser? 一个与Selenium有关的额外问题,如果有人想向前走-鉴于用户将收到的访问令牌是特定于浏览器的并且Selenium将运行无头浏览器,您如何检查用户是否登录到特定网站? And is there a secure way to prompt the users to log in if they are not already? 有没有一种安全的方式提示用户登录(如果尚未登录)?

登录验证仍然是一个悬而未决的问题,但是事实证明,如果您将脚本分发到软件包中,则可能需要setup.py文件中的依赖项Require Dependencies

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM