运行train.py对象检测脚本时没有名为'tensorflow'的模块

时间:2020-04-28 06:24:04

标签: python-3.x tensorflow ubuntu module object-detection

我试图在tensorflow models / research / object_detection / legacy目录中运行train.py脚本,但是当我遇到错误时,没有名为“ tensorflow”的模块,如下所示。但是我已经安装了tensorflow。

# issue all these cmds on local machine
sudo apt-get install sshfs 
sudo adduser <username> fuse

mkdir ~/remoteserv    
sshfs -o idmap=user <username>@<ipaddress>:/remotepath ~/remoteserv

我在这里安装了tensorflow 2.0.0:

paperspace@psynjt4iq:~$ cd '/home/paperspace/Desktop/models/research' 
paperspace@psynjt4iq:~/Desktop/models/research$ protoc object_detection/protos/*.proto --python_out=.
paperspace@psynjt4iq:~/Desktop/models/research$ export PYTHONPATH=$PYTHONPATH:'pwd':'pwd'/slim
paperspace@psynjt4iq:~/Desktop/models/research$ cd object_detection/legacy
paperspace@psynjt4iq:~/Desktop/models/research/object_detection/legacy$ python3 train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/pipeline.config
Traceback (most recent call last):
  File "train.py", line 47, in <module>
    import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'

有什么我想念的吗?

2 个答案:

答案 0 :(得分:0)

您是否按以下方式导出python路径?

export PYTHONPATH = $ PYTHONPATH:pwdpwd / slim

希望有帮助吗?

答案 1 :(得分:0)

您在系统2和3中是否同时拥有两个版本的python。

如果是这种情况,则添加

导出PYTHONPATH = /您的/ tensorflow /路径:$ PYTHONPATH 也许可以解决这个问题。