工作需要,下载 rknn-toolkit 开发套件时,需要事先进行python 环境配置,然后就遇到这个问题,卡了我好久。。。。。(还是自己菜,唉。)BUG具体如下:**
这是开始的命令,它就是BUG的潘多拉魔盒:

(venv) shopping1@ubuntu:~/rk3399pro_linux/external/rknn-toolkit/packages$ pip install -r ./requirements-cpu.txt

** 中间有很长一段是第三方库安装成功的记录,就不给你们看了,直接看BUG处吧,下面其实有大半都是红色字体,复制过来我不会弄,搞成全是一样的颜色了。:**

Using cached https://files.pythonhosted.org/packages/c0/4e/fd492e91abdc2d2fcb70ef453064d980688762079397f779758e055f6575/Markdown-3.1.1-py2.py3-none-any.whl
Building wheels for collected packages: lmdbBuilding wheel for lmdb (setup.py) ... errorERROR: Complete output from command /home/shopping1/venv/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-vg8t53ai/lmdb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-u2ozrkg_ --python-tag cp36:ERROR: py-lmdb: Using bundled liblmdb; override with LMDB_FORCE_SYSTEM=1.py-lmdb: Using CPython extension; override with LMDB_FORCE_CFFI=1.running bdist_wheelrunning buildrunning build_pycreating buildcreating build/lib.linux-x86_64-3.6creating build/lib.linux-x86_64-3.6/lmdbcopying lmdb/cffi.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/__main__.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/tool.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/_config.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/__init__.py -> build/lib.linux-x86_64-3.6/lmdbrunning build_extbuilding 'cpython' extensioncreating build/temp.linux-x86_64-3.6creating build/temp.linux-x86_64-3.6/lmdbcreating build/temp.linux-x86_64-3.6/libx86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ilib/py-lmdb -Ilib -I/usr/include/python3.6m -I/home/shopping1/venv/include/python3.6m -c lmdb/cpython.c -o build/temp.linux-x86_64-3.6/lmdb/cpython.o -UNDEBUG -wlmdb/cpython.c:42:10: fatal error: Python.h: No such file or directory#include "Python.h"^~~~~~~~~~compilation terminated.error: command 'x86_64-linux-gnu-gcc' failed with exit status 1----------------------------------------ERROR: Failed building wheel for lmdbRunning setup.py clean for lmdb
Failed to build lmdb
Installing collected packages: lmdb, decorator, networkx, typing, typing-extensions, onnx, itsdangerous, MarkupSafe, Jinja2, click, Werkzeug, flask, dill, opencv-python, ruamel.yaml, wrapt, keras-applications, tensorflow-estimator, grpcio, gast, keras-preprocessing, absl-py, markdown, tensorboard, google-pasta, astor, termcolor, tensorflowRunning setup.py install for lmdb ... errorERROR: Complete output from command /home/shopping1/venv/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-vg8t53ai/lmdb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-yamu_5n9/install-record.txt --single-version-externally-managed --compile --install-headers /home/shopping1/venv/include/site/python3.6/lmdb:ERROR: py-lmdb: Using bundled liblmdb; override with LMDB_FORCE_SYSTEM=1.py-lmdb: Using CPython extension; override with LMDB_FORCE_CFFI=1.running installrunning buildrunning build_pycreating buildcreating build/lib.linux-x86_64-3.6creating build/lib.linux-x86_64-3.6/lmdbcopying lmdb/cffi.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/__main__.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/tool.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/_config.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/__init__.py -> build/lib.linux-x86_64-3.6/lmdbrunning build_extbuilding 'cpython' extensioncreating build/temp.linux-x86_64-3.6creating build/temp.linux-x86_64-3.6/lmdbcreating build/temp.linux-x86_64-3.6/libx86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ilib/py-lmdb -Ilib -I/usr/include/python3.6m -I/home/shopping1/venv/include/python3.6m -c lmdb/cpython.c -o build/temp.linux-x86_64-3.6/lmdb/cpython.o -UNDEBUG -wlmdb/cpython.c:42:10: fatal error: Python.h: No such file or directory#include "Python.h"^~~~~~~~~~compilation terminated.error: command 'x86_64-linux-gnu-gcc' failed with exit status 1----------------------------------------
ERROR: Command "/home/shopping1/venv/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-vg8t53ai/lmdb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-yamu_5n9/install-record.txt --single-version-externally-managed --compile --install-headers /home/shopping1/venv/include/site/python3.6/lmdb" failed with error code 1 in /tmp/pip-install-vg8t53ai/lmdb/

回到主题,字里行间都提到 lmdb 这个库,所以我猜想是不是它没法安装引起的,于是想到自己手动安装。一开始输入 python ,进入python 命令行里下载,结果不行:

(venv) shopping1@ubuntu:~/rk3399pro_linux/external/rknn-toolkit/packages$ python
Python 3.6.8 (default, Jan 14 2019, 11:02:34)
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> pip install lmdbFile "<stdin>", line 1pip install lmdb^
SyntaxError: invalid syntax
>>> pip install lmdbFile "<stdin>", line 1pip install lmdb^
SyntaxError: invalid syntax
>>> quit()

后来退出 python 命令行,在ubuntu 终端里,输入以下命令:

(venv) shopping1@ubuntu:~/rk3399pro_linux/external/rknn-toolkit/packages$ pip install lmdb
Collecting lmdbUsing cached https://files.pythonhosted.org/packages/86/5c/6ad690daeaa00b328606bf2fa435244a11cc2dd9aedac6ef4d2ef2a21f6e/lmdb-0.96.tar.gz
Building wheels for collected packages: lmdbBuilding wheel for lmdb (setup.py) ... errorERROR: Complete output from command /home/shopping1/venv/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-bzqbulh7/lmdb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-dnybrxi9 --python-tag cp36:ERROR: py-lmdb: Using bundled liblmdb; override with LMDB_FORCE_SYSTEM=1.py-lmdb: Using CPython extension; override with LMDB_FORCE_CFFI=1.running bdist_wheelrunning buildrunning build_pycreating buildcreating build/lib.linux-x86_64-3.6creating build/lib.linux-x86_64-3.6/lmdbcopying lmdb/cffi.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/__main__.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/tool.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/_config.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/__init__.py -> build/lib.linux-x86_64-3.6/lmdbrunning build_extbuilding 'cpython' extensioncreating build/temp.linux-x86_64-3.6creating build/temp.linux-x86_64-3.6/lmdbcreating build/temp.linux-x86_64-3.6/libx86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ilib/py-lmdb -Ilib -I/usr/include/python3.6m -I/home/shopping1/venv/include/python3.6m -c lmdb/cpython.c -o build/temp.linux-x86_64-3.6/lmdb/cpython.o -UNDEBUG -wlmdb/cpython.c:42:10: fatal error: Python.h: No such file or directory#include "Python.h"^~~~~~~~~~compilation terminated.error: command 'x86_64-linux-gnu-gcc' failed with exit status 1----------------------------------------ERROR: Failed building wheel for lmdbRunning setup.py clean for lmdb
Failed to build lmdb
Installing collected packages: lmdbRunning setup.py install for lmdb ... errorERROR: Complete output from command /home/shopping1/venv/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-bzqbulh7/lmdb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7cmwe2vk/install-record.txt --single-version-externally-managed --compile --install-headers /home/shopping1/venv/include/site/python3.6/lmdb:ERROR: py-lmdb: Using bundled liblmdb; override with LMDB_FORCE_SYSTEM=1.py-lmdb: Using CPython extension; override with LMDB_FORCE_CFFI=1.running installrunning buildrunning build_pycreating buildcreating build/lib.linux-x86_64-3.6creating build/lib.linux-x86_64-3.6/lmdbcopying lmdb/cffi.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/__main__.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/tool.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/_config.py -> build/lib.linux-x86_64-3.6/lmdbcopying lmdb/__init__.py -> build/lib.linux-x86_64-3.6/lmdbrunning build_extbuilding 'cpython' extensioncreating build/temp.linux-x86_64-3.6creating build/temp.linux-x86_64-3.6/lmdbcreating build/temp.linux-x86_64-3.6/libx86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -Ilib/py-lmdb -Ilib -I/usr/include/python3.6m -I/home/shopping1/venv/include/python3.6m -c lmdb/cpython.c -o build/temp.linux-x86_64-3.6/lmdb/cpython.o -UNDEBUG -wlmdb/cpython.c:42:10: fatal error: Python.h: No such file or directory#include "Python.h"^~~~~~~~~~compilation terminated.error: command 'x86_64-linux-gnu-gcc' failed with exit status 1----------------------------------------
ERROR: Command "/home/shopping1/venv/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-bzqbulh7/lmdb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7cmwe2vk/install-record.txt --single-version-externally-managed --compile --install-headers /home/shopping1/venv/include/site/python3.6/lmdb" failed with error code 1 in /tmp/pip-install-bzqbulh7/lmdb/

发现这个错误和上面的错误是一样的,这证明我的猜想是对的,BUG和 lmdb 有关,于是再次输入:

(venv) shopping1@ubuntu:~/rk3399pro_linux/external/rknn-toolkit/packages$ sudo pip install lmdb
[sudo] password for shopping1:
The directory '/home/shopping1/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/shopping1/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting lmdbDownloading https://files.pythonhosted.org/packages/86/5c/6ad690daeaa00b328606bf2fa435244a11cc2dd9aedac6ef4d2ef2a21f6e/lmdb-0.96.tar.gz (869kB)100% |████████████████████████████████| 870kB 22kB/s
Installing collected packages: lmdbRunning setup.py install for lmdb ... done
Successfully installed lmdb-0.96

试着这样输入,结果成功安装,当时真快要叫出来,不过还好没叫,很快就打脸了。

(venv) shopping1@ubuntu:~/rk3399pro_linux/external/rknn-toolkit/packages$ pip install -r ./requirements-cpu.txt

再次输入这个鬼命令,满心欢喜的等待它全部KO的时候,又报错了,和上面一样,草。在怀疑自己刚才是不是真的成功安装了 lmdb 时,输入下面命令看了一样,启发了我:

(venv) shopping1@ubuntu:~/rk3399pro_linux/external/rknn-toolkit/packages$ sudo pip install lmdb
The directory '/home/shopping1/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/shopping1/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: lmdb in /usr/local/lib/python2.7/dist-packages

可以看见该库安装在 python 2.7下面,而我输入以下:

(venv) shopping1@ubuntu:~/rk3399pro_linux/external/rknn-toolkit/packages$ python --version
Python 3.6.8

这两个对不上,所以怀疑是不是库默认安装路径错,应该安装在python3.6下面。所以,有以下操作。
先卸载 lmdb 库:

(venv) shopping1@ubuntu:/usr/local/lib/python3.6/dist-packages$ sudo pip uninstall lmdb
[sudo] password for shopping1:
The directory '/home/shopping1/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling lmdb-0.96:/usr/local/lib/python2.7/dist-packages/lmdb-0.96-py2.7.egg-info/usr/local/lib/python2.7/dist-packages/lmdb/__init__.py/usr/local/lib/python2.7/dist-packages/lmdb/__init__.pyc/usr/local/lib/python2.7/dist-packages/lmdb/__main__.py/usr/local/lib/python2.7/dist-packages/lmdb/__main__.pyc/usr/local/lib/python2.7/dist-packages/lmdb/_config.py/usr/local/lib/python2.7/dist-packages/lmdb/_config.pyc/usr/local/lib/python2.7/dist-packages/lmdb/cffi.py/usr/local/lib/python2.7/dist-packages/lmdb/cffi.pyc/usr/local/lib/python2.7/dist-packages/lmdb/cpython.so/usr/local/lib/python2.7/dist-packages/lmdb/tool.py/usr/local/lib/python2.7/dist-packages/lmdb/tool.pyc
Proceed (y/n)? ySuccessfully uninstalled lmdb-0.96

再重新安装,记得加好路径,而且该路径是你目前使用 python 版本的路径,这点要记得。

(venv) shopping1@ubuntu:/usr/local/lib/python3.6/dist-packages$ sudo pip install --target=./ lmdb
The directory '/home/shopping1/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/shopping1/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting lmdbDownloading https://files.pythonhosted.org/packages/86/5c/6ad690daeaa00b328606bf2fa435244a11cc2dd9aedac6ef4d2ef2a21f6e/lmdb-0.96.tar.gz (869kB)100% |████████████████████████████████| 870kB 20kB/s
Installing collected packages: lmdbRunning setup.py install for lmdb ... done
Successfully installed lmdb-0.96

因为我在目标目录里,所以这样写,你们不要学我啊!!! 之后再次输入命令:

(venv) shopping1@ubuntu:~/rk3399pro_linux/external/rknn-toolkit/packages$ sudo pip install -r ./requirements-cpu.txt

在揪心了几分钟后,终于好了,BUG解除!!!发个纪录,分享一下喜悦。

Successfully uninstalled tensorflow-0.9.0
Successfully installed Jinja2-2.10.1 MarkupSafe-1.1.1 Werkzeug-0.15.5 absl-py-0.7.1 astor-0.8.0
backports.weakref-1.0.post1 click-7.0 decorator-4.4.0 dill-0.2.8.2 flask-1.1.1 flatbuffers-1.9 funcsigs-1.0.2
futures-3.3.0 gast-0.2.2 google-pasta-0.1.7 grpcio-1.22.0 h5py-2.9.0 itsdangerous-1.1.0
keras-applications-1.0.8 keras-preprocessing-1.1.0 lmdb-0.96 markdown-3.1.1 mock-3.0.5 networkx-1.11 onnx-1.5.0
opencv-python-4.1.0.25 protobuf-3.9.0 ruamel.ordereddict-0.4.13 ruamel.yaml-0.15.82 scipy-1.2.2 tensorboard-1.14.0
tensorflow-1.14.0 tensorflow-estimator-1.14.0 termcolor-1.1.0 typing-3.7.4 typing-extensions-3.7.4 wrapt-1.11.2

这个鬼东西卡了我好几个小时,特意发帖纪录,共同进步!!!

菜鸟落泪:配置python 环境时,遇到关于 lmdb 模块的问题。相关推荐

  1. python vscode_VScode || 为VScode配置python环境

    随着逐渐参与到TUF项目中,学习python势在必行,因此,是时候为VScode配置python环境了. 目录: Ⅰ 从官网下载python Ⅱ 安装python并将python加入到path Ⅲ 检 ...

  2. 【Ubuntu】Ubuntu16.04配置python环境(vim、ipython)

    在Ubuntu16.04中配置python环境   继Ubuntu16.04+VMware+Win10安装及配置教程之后,我们便可以在Ubuntu平台上开发python程序.   ubuntu16.0 ...

  3. 黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第一章 配置python环境

    黑帽python第二版(Black Hat Python 2nd Edition)读书笔记 之 第一章 配置python环境 文章目录 黑帽python第二版(Black Hat Python 2nd ...

  4. 日报 1 | 配置Python环境

    一.今日学习计划 安装anachor和pycharm 对anachor和pycharm进行python环境的配置 二.知识 1.一些概念 环境变量是操作系统提供给应用程序访问的简单 key / val ...

  5. VScode配置Python环境配置不上问题解决

    一.下载VSCode VScode去官网直接下,然后安装就好. 二.安装python 下载地址:https://www.python.org/downloads/ 安装时选择配置环境: 三.VScod ...

  6. Vim配置Python环境

    前言 Vim是一款非常好用的IDE,特别是在Linux中. 但是其的配置过程十分麻烦. 检测Vim版本 ~$ vim --version VIM - Vi IMproved 8.1 (2018 May ...

  7. vscode找不到python环境_在vscode成功配置Python环境

    注意:如果您希望在Visual Studio Code中开始使用Python,请参阅教程.本文仅关注设置Python解释器/环境的各个方面. Python中的"环境"是Python ...

  8. VScode上配置python环境过程

    前言:网站上也有很多详细的教程.但总所周知每个人的计算机是不一样的,遇到的问题也会不一样,此次只是记录本人安装Python的过程. 目录 1.下载VScode 2.在vs安装python插件 3.配置 ...

  9. VS2019配置opencv环境时找不到Microsoft.Cpp.x64.user.props

    安装下面方式,Microsoft.Cpp.x64.user.props有了 但是配置显示不可用: VS2019配置opencv环境时找不到Microsoft.Cpp.x64.user.props 用实 ...

最新文章

  1. android GridView item中组件获取焦点
  2. oschina添加ssh公钥一记
  3. Kindeditor中上传本地照片后需要带域名的绝对路径实际获取为相对路径
  4. python探测端口_python检测远程服务器tcp端口的方法
  5. marker主题 ros_(五)ROS主题理解
  6. 计算机的应用可以分为几类,计算机分为哪几类专业
  7. 【Hbase】eclipse下远程调试Hbase
  8. 佳士得于5月19日至27日以NFT形式拍卖安迪·沃霍尔作品
  9. Spring MVC 使用问题与解决--HTTP Status 500 - Servlet.init() for servlet springmvc threw exception
  10. 电脑主机启动不了是什么原因
  11. Redis--发布订阅
  12. android判断进程是否是意外退出
  13. Maven —— was cached in the local repository, resolution will not be reattempted until the update ...
  14. ubuntu20.04桌面美化
  15. Epoll水平触发(Level Triggered)工作模式和边缘触发(Edge Triggered)工作模式区别
  16. 树莓派之安装Vulkan
  17. Linux 工具 | 第1篇:高级流控-TC+HTB+IFB+内核模块
  18. h5微信f分享链接给对方获取对方手机号_企业微信可以搜索微信号添加好友/客户吗?怎样主动添加通过率高?...
  19. 四川双流高中2021高考成绩查询,超全!2019四川各地高中高考喜报汇总!
  20. 服务器该不该选SSD硬盘储存?

热门文章

  1. Linux应用开发学习路线图
  2. 应用多线程抓取小米应用商店的例子
  3. Java使用MD5加盐对密码进行加密处理,附注册和登录加密解密处理
  4. Java高并发编程学习(三)java.util.concurrent包
  5. 应届生找工作到哪里找
  6. delphi10.4使用uniGUI
  7. 【寒假每日一题】AcWing 4510. 寻宝!大冒险!
  8. 电脑WLAN连接异常:自上次连接后,某些信息已更改。我们还需要一些信息才能完成连接。
  9. 【MySQL】MySQL复制原理与主备一致性同步工作原理解析(原理篇)(MySQL专栏启动)
  10. WPS 2019 去除自动升级 和 广告、及优化的点