gpt4 book ai didi

python - 在 virtualenv 中安装 oursql 时出错

转载 作者:行者123 更新时间:2023-11-29 06:18:26 27 4
gpt4 key购买 nike

当我尝试使用 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 并获得了以下输出:

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.
The directory '/home/raghav/.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 oursql
Downloading oursql-0.9.3.1.tar.bz2 (119kB)
100% |████████████████████████████████| 122kB 986kB/s
Installing collected packages: oursql
Running setup.py install for oursql
Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-GbfPiA/oursql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-avSCME-record/install-record.txt --single-version-externally-managed --compile:
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
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

----------------------------------------
Command "/usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-GbfPiA/oursql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-avSCME-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-GbfPiA/oursql

出了什么问题?我无法找出答案。

最佳答案

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 用户所有,你的用户不能在那里写。你永远不应该以 root 身份使用 virtualenv。

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

更改权限

关于python - 在 virtualenv 中安装 oursql 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34597290/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com