英文:
Problem installing a Python program from GitHub
问题
我正在尝试安装MQTT模拟器。
我已经在我的计算机上安装了Python v3.3.10。我在这个视频中的1:48到5:43之间进行了操作,所以现在我桌面上有一个名为python_project的文件夹,里面有一个名为venv的文件夹。
我已经从GitHub上下载了mqtt-simulator-master,并将其放在python_project中,并将mqtt-simulator-master的内容复制到python project中。我已经激活了虚拟环境,命令是 C:\Users\Me\Desktop\python_project>.\venv\Scripts\activate
。
然后我在CMD中输入了 C:\Users\Jaime\Desktop\python_project>python3 -m venv venv
,没有看到任何可见的输出。
下一行是 source venv/bin/activate
,结果出现错误,错误信息说source是一个不被识别的命令。
然后我输入了 pip3 install -r requirements.txt
。这给出了一个带有警告的输出:
> 警告:paho-mqtt正在使用传统的"setup.py install"方法进行安装,因为它没有"pyproject.toml"文件,而"wheel"包未安装。pip 23.1将强制执行此行为更改。一个可能的替代方法是启用"--use-pep517"选项。可以在https://github.com/pypa/pip/issues/8559中找到讨论。
以及输出 成功安装了paho-mqtt-1.5.0
。
然而,如果我输入 python3 mqtt-simulator/main.py
,我会得到以下错误:
> 文件 "C:\Users\Me\Desktop\python_project\mqtt-simulator\main.py",行 3,in
from simulator import Simulator 文件 "C:\Users\Me\Desktop\python_project\mqtt-simulator\simulator.py",行 2,in <module> from topic import TopicAuto 文件 "C:\Users\Me\Desktop\python_project\mqtt-simulator\topic.py",行 6,in <module> import paho.mqtt.client as mqtt ModuleNotFoundError: No module named 'paho'
我需要一些建议,关于如何使这个工作,因为我对该怎么做一无所知。
英文:
I am trying to install the MQTT simulator.
I have python v3.3.10 installed in my computer. I followed this video between 1:48 and 5.43, so now I have a folder in my desktop called python_project, inside of which there is a folder called venv.
I have downloaded the mqtt-simulator-master from git hub and put it inside of python_project and copied the contents of mqtt-simulator-master onto python project itself. I have activated the virtual environment as C:\Users\Me\Desktop\python_project>.\venv\Scripts\activate
.
Then I have written in the CMD C:\Users\Jaime\Desktop\python_project>python3 -m venv venv
which didn't have any visible output.
The next line was source venv/bin/activate
, which resulted in an error, which said that source is an unrecognized command.
Then I wrote pip3 install -r requirements.txt
. This gave me an output with the warning
> DEPRECATION: paho-mqtt is being installed using the legacy 'setup.py
> install' method, because it does not have a 'pyproject.toml' and the
> 'wheel' package is not installed. pip 23.1 will enforce this behaviour
> change. A possible replacement is to enable the '--use-pep517' option.
> Discussion can be found at https://github.com/pypa/pip/issues/8559
and the output Successfully installed paho-mqtt-1.5.0
However, if I write python3 mqtt-simulator/main.py
, i get the following error:
> File "C:\Users\Me\Desktop\python_project\mqtt-simulator\main.py",
> line 3, in <module>
> from simulator import Simulator File "C:\Users\Me\Desktop\python_project\mqtt-simulator\simulator.py",
> line 2, in <module>
> from topic import TopicAuto File "C:\Users\Me\Desktop\python_project\mqtt-simulator\topic.py", line
> 6, in <module>
> import paho.mqtt.client as mqtt ModuleNotFoundError: No module named 'paho'
I need some tips on how to make this work since I am clueless about what to do.
答案1
得分: 1
我已经按照相同的说明成功运行了git文件。我猜想你可能在环境设置方面出了问题,就像你可能在不同的环境中安装了要求并在不同的环境中运行代码。做一件事:
调试步骤可能会帮助你:
- 打开一个全新的命令提示符,不要创建任何环境
- 运行
pip3 install paho-mqtt==1.5.0
- 然后进入文件夹,或者像这样运行
python3 Desktop\python_project\mqtt-simulator\main.py
(假设cmd在C:\Users\Me\
)
看看你会得到什么。
英文:
I've followed the same instructions I'm able to sucessfully run the git files. I'm guessing you messing up env's like u may installing requiremnts in different env and may running code in different environment. Do one thing
Debugging steps may help you:
- Take a fresh cmd don't create any environment
- run
pip3 install paho-mqtt==1.5.0
- Then go to folder or run like
python3 Desktop\python_project\mqtt-simulator\main.py
(assuming cmd atC:\Users\Me\
)
see what you will get.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论