Python找不到模块

发布于 2025-01-19 05:12:20 字数 453 浏览 3 评论 0原文

我正在尝试在我的服务器(主机/共享托管)上运行网络抓取脚本,它们使用名为 virtualenv 的东西(我做了一些研究,它令人困惑......)。不过,我确实安装了运行 Selenium 和其他一些进程所需的软件包。我已经通过运行以下命令检查了它们是否已安装:

$ pip show selenium

它返回 Location: /home/s49674/virtualenv/python/3.9/lib/python3.9/site-packages

但是,当我运行 python 时代码,它给了我模块未安装的错误。

我要做的就是通过ssh激活virtualenv,并通过ssh调用python脚本。但这不允许我通过 cronjob 自动执行脚本。你知道这个问题的解决办法吗?到目前为止我还没有找到任何有效的东西。无论我将 python 脚本存储在哪里,它都找不到模块。

I'm trying to run scripts for webscraping on my server (host/shared hosting) and they use something called virtualenv (I've done some research and its confusing...). However, I did install the required packages for running Selenium and some other processes. I have checked that they are installed by running the command:

$ pip show selenium

Which returns Location: /home/s49674/virtualenv/python/3.9/lib/python3.9/site-packages

However, when I run my python code, it gives me the error that the module is not installed.

What I have to do is to activate the virtualenv through ssh, and call the python script through the ssh. But this doesn't allow me to automate script execution through cronjob. Do you know a solution to this? So far I haven't found anything that works. It doesnt matter where I store the python script, it cant find the modules.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文