Hi. I have been installing pytorch multiple times. I took into consideration the python environment I was using. After all these, the code that I run still says ModuleNotFoundError: No module named ‘torch’. Could anyone help me in these. I copy the error message below. (I was trying to use stanza to evaluate a model, sorry just a beginner)
(my-torch) Toufig-Lu:stanza yiminglu$ python3 -m stanza.utils.datasets.prepare_mwt_treebank UD_English-TEST
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/Users/yiminglu/Desktop/stanza-train-master/stanza-train/stanza/stanza/__init__.py", line 1, in <module>
from stanza.pipeline.core import DownloadMethod, Pipeline
File "/Users/yiminglu/Desktop/stanza-train-master/stanza-train/stanza/stanza/pipeline/core.py", line 9, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
I did these multiple times. I created another environment in anaconda, and I did it directly in anaconda, I used pip. At the end, the response is all the same.
Ok, so let’s use the conda environment for the meanwhile. Are you using an integrated developer environment (IDE) like PyCharm, VScode, etc? If so, you’ll need to select the environment within the IDE as well (instead of just the terminal) and select the correct python interpreter, because it’ll default to your base environment that doesn’t have pytorch installed.
You can check what environment you’re using (in conda) via using conda env list within the terminal, you’ll see a * next to the environment you’re using. Could you check that?
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/Users/yiminglu/Desktop/stanza-train-master/stanza-train/stanza/stanza/__init__.py", line 1, in <module>
from stanza.pipeline.core import DownloadMethod, Pipeline
File "/Users/yiminglu/Desktop/stanza-train-master/stanza-train/stanza/stanza/pipeline/core.py", line 9, in <module>
import torch
ModuleNotFoundError: No module named 'torch'