简体   繁体   English

为什么我的电脑不能运行从sympy导入的Python程序

[英]Why won't my computer run Python programs that import from sympy

I write this simple little Python program to give me the prime factors of a number:我写了这个简单的小 Python 程序来给我一个数的质因数:

from sympy import primefactors
number = int(input("Enter a number: "))
print("Prime factors", primefactors(number))

The program works when run within the Anaconda IDE but not outside of it - at least not on my computer.该程序在 Anaconda IDE 内运行时有效,但不在它之外 - 至少在我的计算机上没有。 It runs perfectly on my wife's laptop and on my son's desktop without the need to launch Anaconda.它可以在我妻子的笔记本电脑和我儿子的台式机上完美运行,无需启动 Anaconda。 They both run Window 10.他们都运行 Window 10。

The same thing happens with any program headed from sympy import * .任何以from sympy import *程序都会发生同样的事情。 When I run the program in IDLE I get the error message当我在 IDLE 中运行程序时,我收到错误消息

ModuleNotFoundError: No module named 'sympy'

Again, if I run the program on another computer I don't have this problem.同样,如果我在另一台计算机上运行该程序,我没有这个问题。

Does the problem lie my computer (i7-3770K, 16 GB RAM, Windows 10) or somewhere else?问题出在我的电脑(i7-3770K、16 GB RAM、Windows 10)还是其他地方?

OK, here's what I did.好的,这就是我所做的。 I had both python and anaconda on my computer, thinking that I needed to install python before anaconda.我的电脑上同时安装了 python 和 anaconda,认为我需要在 Z7E3332C5FD0270D497C964E58211 之前安装 python。 I deleted them both and then and reinstalled anaconda only.我删除了它们,然后只重新安装了 anaconda。 The problem programs now work as expected.问题程序现在按预期工作。 Sorry if I've inconvenienced anyone.对不起,如果我给任何人带来不便。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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