2017-08-09 81 views
0

我想使用physics.quantum.TensorProduct' method in sympy`。看看the repo这个方法肯定存在。试图导入到我的Python会话然而,当我得到如下:在本地版本的python包中找不到回购模块

>>> from sympy import * 
>>> physics.quantum.TensorProduct(v1,v2) 
Traceback (most recent call last): 
    File "<pyshell#271>", line 1, in <module> 
    physics.quantum.TensorProduct(v1,v2) 
AttributeError: module 'sympy.physics' has no attribute 'quantum' 

我用无缝作为pip安装pip install sympy sympy。如果我尝试升级pip install sympy --upgrade,我收到Requirement already up-to-date消息。

这是为什么这个脚本不包括在内?我如何得到它,以便它从repo下载并在我的python会话中识别?

感谢

+0

您确定安装的sympy版本与存储库中的版本匹配吗?也许运行'pip freeze'来查看你安装的软件包的版本。 – jobou

+0

'pip freeze'显示我正在使用'sympy 1.1.1'。我如何知道存储库现在位于哪个版本? – user32882

回答

2

看来,physics包不sympy.__init__.__all__进口的,所以你不能用一个简单的from sympy import *

>>> from sympy import * 
>>> 'physics' in dir() 
False 

访问它在本地范围相反,你可以导入想手动类。例如:

>>> import sympy.physics.quantum.tensorproduct 
>>> sympy.physics.quantum.tensorproduct.TensorProduct 
<class 'sympy.physics.quantum.tensorproduct.TensorProduct'> 
+0

我输入错了。谢谢 – user32882