[英]import torch ModuleNotFoundError: No module named 'torch'
Help me understand few things, im new with python and all these depended libraries.帮助我理解一些东西,我是 Python 新手和所有这些依赖库。
I m trying to run a project which is written in python.我正在尝试运行一个用 python 编写的项目。 Git repository can be found here: https://github.com/ifzhang/FairMOT
Git 存储库可以在这里找到: https : //github.com/ifzhang/FairMOT
On anaconda prompt I have been running these commands:在 anaconda 提示符下,我一直在运行这些命令:
conda create -n FairMOT
conda activate FairMOT
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
cd ${FAIRMOT_ROOT}
pip install -r requirements.txt
All being successfully installed全部安装成功
I have performed all the steps that were listed in the Readme file我已执行自述文件中列出的所有步骤
Now there is training step which requires to run shell script.现在有需要运行shell脚本的训练步骤。
Assuming the fact that shell script would not be called on anaconda prompt, I switched to git bash, and I run the script (keeping in mind of path)假设不会在 anaconda 提示符下调用 shell 脚本,我切换到 git bash,然后运行脚本(记住路径)
sh experiments/crowdhuman_dla34.sh
it throws error它抛出错误
Sanam@LAPTOP-NPVR76P7 MINGW64 /f/NTNU/Deep learning/Repositories/FairMOT (master)
$ sh experiments/crowdhuman_dla34.sh
Traceback (most recent call last):
File "train.py", line 10, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
Question is: is there any other console where I need to run this command other than git bash?问题是:除了 git bash 之外,是否还有其他控制台需要我运行此命令? it would definitely not work on anaconda prompt.
它绝对不会在 anaconda 提示符下工作。 what im doing wrong?
我做错了什么?
coming back to anaconda prompt, when I test import there, it worked回到 anaconda 提示,当我在那里测试导入时,它起作用了
(FairMOT) F:\NTNU\Deep learning\Repositories\FairMOT>python
Python 3.7.9 (default, Aug 31 2020, 17:10:11) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>>
where & how do I run this command?我在哪里以及如何运行此命令? so that it would work?is running on git bash not good?
这样它就可以工作了?在 git bash 上运行不好?
thanks in advance!!提前致谢!!
PS: I have already tried reinstalling, activation/ deactivation of environment but it does not work PS:我已经尝试过重新安装,激活/停用环境但它不起作用
Pls.请。 create a virtual envrionment first, then install all the dependencies there.
首先创建一个虚拟环境,然后在那里安装所有依赖项。 Use the same venv in anaconda and run the bash script in any terminal with the venv activated.
在 anaconda 中使用相同的 venv 并在激活 venv 的任何终端中运行 bash 脚本。
Also, you can run which python
to ensure you are installing and then importing it from same python interpreter此外,您可以运行
which python
以确保您正在安装,然后从同一个 python 解释器导入它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.