简体   繁体   中英

module in repo not found in local version of python package

I would like to use the physics.quantum.TensorProduct' method in sympy`. Looking at the repo this method definitely exists. However when attempting to import into my python session I get the following:

>>> 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'

I installed sympy seamlessly using pip as pip install sympy . If I try to upgrade pip install sympy --upgrade I get the Requirement already up-to-date message.

Why is this that this script is not included? How can I get it so that it is downloaded from the repo and recognized in my python session?

Thanks

It seems that the physics package is not imported in sympy.__init__.__all__ so you cannot access it in your local scope with a simple from sympy import *

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

Instead you could import the class you want manually. For example :

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

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