我像这样编写一个代码test.py:
import soundfile
print("import success")
当我尝试在Windows 7上运行它时,我只能通过cmd成功运行:
python test.py
但我不能通过双击test.py来运行它,它太快而无法消失,我可以看到它显示:
no module named soundfile
我注意到,当我在Windows 10上双击test.py时,它成功了。
THX到@BoarGules,使用
where python
在cmd。我在regedit HKEY_CLASSES_ROOT \ Python.File \ shell \ open \ command中将python路径从python2.7替换为python3。然后双击工作!