在virtualen中安装oursql时出错

2024-09-30 01:33:43 发布

您现在位置:Python中文网/ 问答频道 /正文

当我试图使用pip install oursql在虚拟环境下安装oursql时,我得到以下错误:

Collecting oursql
  Using cached oursql-0.9.3.1.tar.bz2
Building wheels for collected packages: oursql
  Running setup.py bdist_wheel for oursql
  Complete output from command /home/raghav/janpro/release_1/venv/bin/python2 -c "import setuptools;__file__='/tmp/pip-build-ndxBoY/oursql/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /tmp/tmpe4k7ejpip-wheel-:
  cython not found, using previously-cython'd .c file.
  running bdist_wheel
  running build
  running build_ext
  warning: no usable mysql_config and no _winreg module to try; hopefully you have usable CFLAGS/LDFLAGS set.
  building 'oursql' extension
  creating build
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/oursqlx
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c oursqlx/oursql.c -o build/temp.linux-x86_64-2.7/oursqlx/oursql.o
  oursqlx/oursql.c:4:20: fatal error: Python.h: No such file or directory
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for oursql
Failed to build oursql
Installing collected packages: oursql
  Running setup.py install for oursql
    Complete output from command /home/raghav/janpro/release_1/venv/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-ndxBoY/oursql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-awH5dT-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/raghav/janpro/release_1/venv/include/site/python2.7/oursql:
    cython not found, using previously-cython'd .c file.
    running install
    running build
    running build_ext
    warning: no usable mysql_config and no _winreg module to try; hopefully you have usable CFLAGS/LDFLAGS set.
    building 'oursql' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c oursqlx/oursql.c -o build/temp.linux-x86_64-2.7/oursqlx/oursql.o
    oursqlx/oursql.c:4:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/home/raghav/janpro/release_1/venv/bin/python2 -c "import setuptools, tokenize;__file__='/tmp/pip-build-ndxBoY/oursql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-awH5dT-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/raghav/janpro/release_1/venv/include/site/python2.7/oursql" failed with error code 1 in /tmp/pip-build-ndxBoY/oursql

然后我用sudo apt-get install libmysqlcppconn-dev安装了MySQL C++ connectors,但仍然出现了错误。在

所以,我尝试了sudo pip install oursql,得到了以下输出:

^{pr2}$

出什么问题了?我找不到。在


Tags: installpippybuildlinuxsetuprecordrunning
2条回答
the directory '/home/raghav/.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.

我想你用sudo pip在你的virtualenv中安装了一些库。所以现在一些文件归root用户所有,用户不能在那里写。你永远不应该使用virtualenv作为根目录。在

如果你有一个requirements.txt文件,我认为最简单的方法是创建一个新的virtualenv并重新安装所有的东西。如果您不想/不能这样做,请尝试使用chown更改权限

您没有安装python开发库。尝试先安装它,然后运行pip。在

sudo apt-get install python2.7-dev

相关问题 更多 >

    热门问题