Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将所有属性导入numpy模块?_Python_Python 3.x_Numpy_Ubuntu 18.04_Jupyter Lab - Fatal编程技术网

Python 如何将所有属性导入numpy模块?

Python 如何将所有属性导入numpy模块?,python,python-3.x,numpy,ubuntu-18.04,jupyter-lab,Python,Python 3.x,Numpy,Ubuntu 18.04,Jupyter Lab,我在使用这个命令时遇到了问题(ubuntu 18.04): 代码示例为: import openseespy.opensees as ops import numpy as np import time import sys print (sys.version) print(np.__version__) pid = ops.getPID() np = ops.getNP() #print(dir(numpy)) prove = np.array([1, 2, 3]) nodi = nump

我在使用这个命令时遇到了问题(ubuntu 18.04):

代码示例为:

import openseespy.opensees as ops
import numpy as np
import time
import sys
print (sys.version)
print(np.__version__)

pid = ops.getPID()
np = ops.getNP()
#print(dir(numpy))
prove = np.array([1, 2, 3])
nodi = numpy.array([[99,0.0,0.0,0.0]]) 

print(nodi,prove)
print('Hello World Process:', pid)
if pid == 0:
    print('Total number of processes:', np)
相对的autput是:

3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0]
1.17.4
Traceback (most recent call last):
  File "hello-Project.py", line 11, in <module>
    prove = np.array([1, 2, 3])
AttributeError: 'int' object has no attribute 'array'
Process 0 Terminating
3.6.8(默认,2019年10月7日12:59:55)
[GCC 8.3.0]
1.17.4
回溯(最近一次呼叫最后一次):
文件“hello Project.py”,第11行,在
prove=np.array([1,2,3])
AttributeError:“int”对象没有属性“array”
进程0正在终止
我使用dir命令查看py脚本中的numpy属性和dont charge属性。 但在命令行中,pythonshell可以工作,我也可以使用jupyterlab

如何解决这个问题

import numpy as np
...
np = ops.getNP()
# any subsequent references to "np" will find the integer, not the numpy module
ops.getNP()
(是一个整数)的结果分配给名称
np
时,您正在隐藏对
numpy
引用

导入
numpy
时将
作为np
删除,或者为
ops.getNP()返回的整数选择另一个名称

ops.getNP()
(是一个整数)的结果分配给名称
np
时,您正在隐藏对
numpy
引用

导入
numpy
时将
作为np
删除,或者为
ops.getNP()返回的整数选择另一个名称

import numpy as np
...
np = ops.getNP()
# any subsequent references to "np" will find the integer, not the numpy module