中断后Python导入无法正常工作

时间:2019-02-27 09:48:59

标签: python tensorflow

我正在运行张量流代码,然后通过ctrl+c中断了它。之后,我立即重新运行了它(无需对代码进行任何调整),现在无法导入任何东西,甚至无法导入tensorflow。我通过google寻找类似问题,但尚未找到任何相关问题。我希望在这里得到一些帮助。

重新运行脚本。

(env_maskrcnn) haziq@vita-workstation2:~/human-pose-3d$ ./run2.sh
Traceback (most recent call last):
  File "src/predict_3dpose.py", line 13, in <module>
    import h5py
ModuleNotFoundError: No module named 'h5py'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "src/predict_3dpose.py", line 13, in <module>
    import h5py
ModuleNotFoundError: No module named 'h5py'

启动python3导入tensorflow

(env_maskrcnn) haziq@vita-workstation2:~/human-pose-3d$ python3
Python 3.7.1 (default, Oct 22 2018, 11:21:55)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

按照Manish Dash给出的说明,我检查了python指向的路径。我正在使用python3,看起来好像没有指向正确的路径。我还检查了文件夹/home/haziq/env_maskrcnn/bin/,但没有看到python3文件。可能会发生什么,我该如何解决?

haziq@vita-workstation2:~$ source env_maskrcnn/bin/activate
(env_maskrcnn) haziq@vita-workstation2:~$ which python
/home/haziq/env_maskrcnn/bin/python
(env_maskrcnn) haziq@vita-workstation2:~$ which python3
/usr/bin/python3

0 个答案:

没有答案