我正试图在tensorflow models/research/object_detection/elegacy目录中运行train.py脚本,但当我这样做时,我遇到了没有名为"tensorflow"的模块的错误,如下所示。但是我安装了tensorflow。
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'
我在这里安装了tensorflow 2.0.0:
paperspace@psynjt4iq:~$ pip3 show tensorflow
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Name: tensorflow
Version: 2.0.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/paperspace/.local/lib/python3.7/site-packages
Requires: google-pasta, protobuf, opt-einsum, keras-preprocessing, keras-applications, six, numpy, grpcio, wheel, astor, tens
我有什么东西不见了吗?
您是否按如下方式导出python路径?
导出PYTHONPATH=$PYTHONPATH:pwd
:pwd
/瘦
希望能有所帮助?
您的系统2&3.
如果是这种情况,那么添加
export PYTHONPATH=/your/tensorflow/path:$PYTHON帕斯也许可以解决这个问题。