与VENV一起在WSL中安装Python要求的问题
完全相同的方式来设置我的本地系统,
我有一个来自供应商的代码存储库,我正在尝试以与他们已经在Windows中使用WSL的Ubuntu 所以我想我会尝试尝试还将此系统用于此供应商回购。在存储库中,有一个看起来像这样的shell脚本:
#!/bin/bash
cd /home/vendorname/vendor-app
. /home/vendorname/.virtualenvs/vendor-app/bin/activate
. /home/vendorname/vendor-app/vendor-environment.sh
python3 /home/vendorname/vendor-app/vendor_script.py
对于参数的情况,让我们称此文件为“ runner.sh”
。将通过家庭下面的Vendorname文件夹的位置建议。不确定这是否是一个问题,但可能是。
其次,我已经设置了我的文件结构与此shell脚本似乎所示的完全相同。我已经将代码存储库放在/home/vendorname下,并使用VENV在/home/vendorname/.virtualenvs/vendor-app下创建了一个虚拟环境。
我还使用以下命令激活了我的虚拟环境:
source /home/vendorname/.virtualenvs/vendor-app/bin/activate
我的问题
从命令行运行runner.sh文件时
Traceback (most recent call last):
File "/home/vendorname/vendor-app/vendor_script.py", line 17, in <module>
import requests
ModuleNotFoundError: No Module named 'requests'
我会收到以下错误:此错误似乎指示未安装请求模块,但是每当我尝试安装时我得到了“已经满足的需求”响应。
有什么想法吗?
I have a code repository from a vendor and I'm trying to set up my local system in the exact same way that they did (as much as possible)
I'm running Ubuntu in WSL for Windows already so I figured I would try to also use this system for this vendor repo. In the repo there is a shell script which looks like this:
#!/bin/bash
cd /home/vendorname/vendor-app
. /home/vendorname/.virtualenvs/vendor-app/bin/activate
. /home/vendorname/vendor-app/vendor-environment.sh
python3 /home/vendorname/vendor-app/vendor_script.py
For case of argument, lets call this file "runner.sh"
First thing to note here is that I do not have a user in my Ubuntu/WSL called 'vendorname' as would be suggested by the location of the vendorname folder under home. Not sure if that is an issue but it might be.
Second, I have set up my file structure exactly the same as this shell script seems to indicate. I have placed my code repository under /home/vendorname and I have used venv to create a virtual environment located under /home/vendorname/.virtualenvs/vendor-app.
I have also activated my virtual environment with the following command:
source /home/vendorname/.virtualenvs/vendor-app/bin/activate
My problem
When I run the runner.sh file from the command line I get the following error:
Traceback (most recent call last):
File "/home/vendorname/vendor-app/vendor_script.py", line 17, in <module>
import requests
ModuleNotFoundError: No Module named 'requests'
This error seems to indicate that the requests module is not installed however whenever I try to install it I get the "Requirement already satisfied" response.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题在Shell脚本的第3行中:
应该看起来像这样:
不确定这是如何工作的,但在本地解决了我的问题
The problem was in line 3 of the shell script:
Which should have looked like this:
Not sure how this ever worked but that fixed my problem locally