[英]Can't import numpy and scipy in Ubuntu for python 3.6.8
我正在尝试将numpy
和scipy
加载到我的 Ubuntu 虚拟机中。
我已确保两者都已安装:
con@VB:~/Scripts$ pip3 install numpy
Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (1.14.2)
con@VB:~/Scripts$ pip3 install scipy
Requirement already satisfied: scipy in /usr/local/lib/python3.6/dist-packages (1.1.0)
Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.6/dist-packages (from scipy) (1.14.2)
但是当我到达python3时:
con@VB:~/Scripts$ python3
Python 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
我收到了这个可怕的信息:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python3.6/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.6/dist-packages/numpy/core/__init__.py", line 35, in <module>
from . import _internal # for freeze programs
File "/usr/local/lib/python3.6/dist-packages/numpy/core/_internal.py", line 9, in <module>
import re
File "/home/con/Scripts/re.py", line 4
print 'string matches'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('string matches')?
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
if not enabled():
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
import re
File "/home/con/Scripts/re.py", line 4
print 'string matches'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('string matches')?
Original exception was:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python3.6/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python3.6/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python3.6/dist-packages/numpy/core/__init__.py", line 35, in <module>
from . import _internal # for freeze programs
File "/usr/local/lib/python3.6/dist-packages/numpy/core/_internal.py", line 9, in <module>
import re
File "/home/con/Scripts/re.py", line 4
print 'string matches'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('string matches')?
这个错误似乎是关于从 python2 切换到 python3 以及 print 语句所需的括号的新手错误,但我没有编写任何这些文件。
我检查了 Python 中的“SyntaxError: Missing parentheses in call to 'print'”是什么意思? 和无法在 python3 中导入 numpy以及如何为 Python 3.6 安装 NumPy但找不到任何有用的解决方案
如何在 python3 中加载 numpy 和 scipy?
你有语法错误。 在 python3 中,您需要使用print("string")
。 不print 'string'
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.