简体   繁体   中英

ModuleNotFoundError: No module named 'pip' in spyder

I tried to use torch in spyder but I got error ModuleNotFoundError: No module named 'torch' so I tried use pip module not in cmd but in spyder itself following

import pip
pip.main(["install","torch"])

but got ModuleNotFoundError: No module named 'pip' and I know I had successfully used it in spyder before but recent automatic spyder updates probably have caused this error so I tried to install pip in my all python environments in cmd with cd {environment_path} but the pip was installed there. I also used python -m ensurepip in all environments but I still get ModuleNotFoundError: No module named 'pip' .

seems the problem is caused by reseting spyder(maybe there other causes) changing different python interpreters (environments) also is no help.! and installing or reinstalling with windows installer solved problem for me.

update: after restarting again many modules like 'pip', 'torch' and 'keyboard' are not recognized and reinstalling is no answer(no difference between installing for 'this user' or 'all users').

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM