【发布时间】:2019-02-16 02:40:47
【问题描述】:
我在安装对象检测 api 时出错,并尝试使用来自该线程 https://github.com/tensorflow/models/issues/1570 的以下解决方案。
mkdir -p ~/installs/protoc_3.3.0
cd ~/installs/protoc_3.3.0
wget https://github.com/google/protobuf/releases/download/v3.3.0/protoc-3.3.0-linux-x86_64.zip
chmod 775 protoc-3.3.0-linux-x86_64.zip
unzip protoc-3.3.0-linux-x86_64.zip
然后:
cd ~/git/models/
~/installs/protoc_3.3.0/bin/protoc object_detection/protos/*.proto --python_out=.
python setup.py install --prefix=~
但上面最后一行代码出现以下错误。
python setup.py install --prefix=~
running install
Checking .pth file support in /home/ayshine/lib/python3.7/site-packages/
/home/ayshine/anaconda3/bin/python -E -c pass
TEST FAILED: /home/ayshine/lib/python3.7/site-packages/ does NOT support .pth files
error: bad install directory or PYTHONPATH
You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from. The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/home/ayshine/lib/python3.7/site-packages/
and your PYTHONPATH environment variable currently contains:
''
Here are some of your options for correcting the problem:
* You can choose a different installation directory, i.e., one that is
on PYTHONPATH or supports .pth files
* You can add the installation directory to the PYTHONPATH environment
variable. (It must then also be on PYTHONPATH whenever you run
Python and want to use the package(s) you are installing.)
* You can set up the installation directory to support ".pth" files by
using one of the approaches described here:
https://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations
Please make the appropriate changes for your system and try again.
【问题讨论】:
-
在我看来问题是您从错误的目录运行命令。应该是:
cd ~/git/models/research/~/installs/protoc_3.3.0/bin/protoc object_detection/protos/*.proto --python_out=.你可以试试这个,它应该会生成所有的协议文件。我不知道第三行是做什么的,但安装指南没有提到使用它。 -
谢谢!我找到答案忘记更新这篇文章了。原来我没有构建 protobuf 并安装它。刚刚下载并解压。但是 protobuf 的 3.4 版对我来说是可行的,尽管不是最新版本。您的回答也是正确的,然后我在安装 protobuf 后从 `~/git/models/research/`` 目录运行此命令。
标签: tensorflow protocol-buffers object-detection