在命令行下from struct import pack, unpack显示正确,但是导入其他包的时候存在from struct import pack时就错误

[复制链接]
查看11 | 回复1 | 2021-1-27 07:15:43 | 显示全部楼层 |阅读模式
写了一个简单的python程序,一直报错
#usr/bin/python
#-*-coding:utf-8-*-
importtensorflowastf
importmatplotlib.pylabasplt
importnumpyasnp
sess=tf.Session()
const=tf.constant([-2.,3.,9.,10.])
$python3plot_tensorflow.py
Traceback(mostrecentcalllast):
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy-1.18.0.dev0+09cb2bd-py3.6-macosx-10.6-intel.egg/numpy/compat/py3k.py",line24,in
importpickle5aspickle
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pickle5/__init__.py",line1,in
from.pickleimport*
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pickle5/pickle.py",line33,in
fromstructimportpack,unpack
ImportError:cannotimportname'pack'
Duringhandlingoftheaboveexception,anotherexceptionoccurred:
Traceback(mostrecentcalllast):
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy-1.18.0.dev0+09cb2bd-py3.6-macosx-10.6-intel.egg/numpy/core/__init__.py",line17,in
from.importmultiarray
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy-1.18.0.dev0+09cb2bd-py3.6-macosx-10.6-intel.egg/numpy/core/multiarray.py",line14,in
from.importoverrides
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy-1.18.0.dev0+09cb2bd-py3.6-macosx-10.6-intel.egg/numpy/core/overrides.py",line9,in
fromnumpy.compat._inspectimportgetargspec
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy-1.18.0.dev0+09cb2bd-py3.6-macosx-10.6-intel.egg/numpy/compat/__init__.py",line14,in
from.importpy3k
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy-1.18.0.dev0+09cb2bd-py3.6-macosx-10.6-intel.egg/numpy/compat/py3k.py",line26,in
importpickle
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/pickle.py",line33,in
fromstructimportpack,unpack
ImportError:cannotimportname'pack'
Duringhandlingoftheaboveexception,anotherexceptionoccurred:
Traceback(mostrecentcalllast):
File"plot_tensorflow.py",line4,in
importtensorflowastf
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/__init__.py",line28,in
fromtensorflow.pythonimportpywrap_tensorflow#pylint:disable=unused-import
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/__init__.py",line27,in
importctypes
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ctypes/__init__.py",line14,in
fromstructimportcalcsizeas_calcsize
File"/Users/yangsen/Desktop/ys/yangsen/code/tensorflow/struct.py",line5,in
importnumpyasnp
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy-1.18.0.dev0+09cb2bd-py3.6-macosx-10.6-intel.egg/numpy/__init__.py",line142,in
from.importcore
File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/numpy-1.18.0.dev0+09cb2bd-py3.6-macosx-10.6-intel.egg/numpy/core/__init__.py",line47,in
raiseImportError(msg)
ImportError:
IMPORTANT:PLEASEREADTHISFORADVICEONHOWTOSOLVETHISISSUE!
Importingthenumpyc-extensionsfailed.
-Tryuninstallingandreinstallingnumpy.
-Ifyouhavealreadydonethat,then:
1.CheckthatyouexpectedtousePython3.6from"/Library/Frameworks/Python.framework/Versions/3.6/bin/python3",
andthatyouhavenodirectoriesinyourPATHorPYTHONPATHthatcan
interferewiththePythonandnumpyversion"1.18.0.dev0+09cb2bd"you'retryingtouse.
2.If(1)looksfine,youcanopenanewissueat
https://github.com/numpy/numpy/issues.Pleaseincludedetailson:
-howyouinstalledPython
-howyouinstallednumpy
-youroperatingsystem
-whetherornotyouhavemultipleversionsofPythoninstalled
-ifyoubuiltfromsource,yourcompilerversionsandideallyabuildlog
-Ifyou'reworkingwithanumpygitrepository,try`gitclean-xdf`
(removesallfilesnotunderversioncontrol)andrebuildnumpy.
Note:thiserrorhasmanypossiblecauses,sopleasedon'tcommenton
anexistingissueaboutthis-openanewoneinstead.
Originalerrorwas:cannotimportname'pack'
分 -->
回复

使用道具 举报

千问 | 2021-1-27 07:15:43 | 显示全部楼层
希望有你能帮忙看一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行