我一直在使用Cython将我的Python文件编译成C文件,然后使用MinGW从C文件创建可执行文件.Cython工作正常,我可以输入cython test.pyx命令行并获得一个C文件.问题是当我尝试从C文件编译可执行文件时.如果我输入,gcc test.c我会收到以下错误:
test.c:4:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
Run Code Online (Sandbox Code Playgroud)
我真的很感激一些帮助.我正在运行Windows 7和python 3.5.
我尝试下载某个软件包时遇到问题:
C:\Python27\Scripts>pip install pycrypto
Collecting pycrypto
Using cached https://files.pythonhosted.org/packages/60/db/645aa9af249f059cc3a368b118de33889219e0362141e75d4eaf6f80f163/pycrypto-2.6.1.tar.gz
Installing collected packages: pycrypto
Running setup.py install for pycrypto ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools
, tokenize;__file__='c:\\users\\beheer~1\\appdata\\local\\temp\\pip-install-_luv
op\\pycrypto\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read(
).replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install
--record c:\users\beheer~1\appdata\local\temp\pip-record-jct20j\install-record.
txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
creating build\lib.win32-2.7\Crypto
copying lib\Crypto\pct_warnings.py -> build\lib.win32-2.7\Crypto
copying lib\Crypto\__init__.py -> build\lib.win32-2.7\Crypto
creating build\lib.win32-2.7\Crypto\Hash
copying lib\Crypto\Hash\hashalgo.py -> build\lib.win32-2.7\Crypto\Hash
copying lib\Crypto\Hash\HMAC.py -> build\lib.win32-2.7\Crypto\Hash
copying lib\Crypto\Hash\MD2.py -> build\lib.win32-2.7\Crypto\Hash
copying lib\Crypto\Hash\MD4.py …Run Code Online (Sandbox Code Playgroud) 在确保自制软件可以在其上运行后,我刚刚购买了一台带有 M1 芯片的新 Macbook Pro。我可以 pip 安装除 mysqlclient 之外的任何其他库,并且通过自制程序安装它没有问题,所以我想从下面的错误消息中看出,这是 mysqlclient 未更新为最新版本 Big 的问题吗? Sur,或者这是新 Mac 本身的问题?只要知道这对我来说就是一个很好的开始,如果您对如何解决它有建议,那就更好了!谢谢你!
ERROR: Command errored out with exit status 1:
command: /Users/danieljonathanschaefer/Desktop/work/401GOVE/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-install-bifqtsix/mysqlclient_6f9d0caea513420ea2052d60956aab6d/setup.py'"'"'; __file__='"'"'/private/var/folders/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-install-bifqtsix/mysqlclient_6f9d0caea513420ea2052d60956aab6d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-record-ukcglom_/install-record.txt --single-version-externally-managed --compile --install-headers /Users/danieljonathanschaefer/Desktop/work/401GOVE/include/site/python3.9/mysqlclient
cwd: /private/var/folders/ht/p0kw7_d11ns61kqmpmfcy6b40000gn/T/pip-install-bifqtsix/mysqlclient_6f9d0caea513420ea2052d60956aab6d/
Complete output (43 lines):
mysql_config --version
['8.0.25']
mysql_config --libs
['-L/opt/homebrew/Cellar/mysql/8.0.25_1/lib', '-lmysqlclient', '-lz', '-lzstd', '-lssl', '-lcrypto', '-lresolv'] …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Ubuntu 上安装 mod_wsgi。当按照 mod_wsgi 网站上的描述运行“sudo make”命令时,我收到错误:
src/server/wsgi_python.h:24:10: fatal error: Python.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
mod_wsgi故障排除部分和 SO(1、2、3)上的其他帖子表示要安装正确版本的 python- dev 。这已经根据以下输出完成。Python3 运行 3.6.7 和 apt-get 说 python3-dev 是最新版本的 3.6.7。
$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
$ sudo apt-get install python3-dev
...
python3-dev is already the newest version (3.6.7-1~18.04).
0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.
Run Code Online (Sandbox Code Playgroud)
所以看起来 Python.h 文件在那里但make找不到它。我看了这篇 SO post ( 4 …
我完成了将包上传到https://test.pypi.org/的教程,并且成功地做到了这一点。
但是,会在目录中$python setup.py sdist bdist_wheel生成一个.whl文件和一个tar.gz文件dist/。twine允许仅上传.whl或tar.gz文件或两者。我看到https://pypi.org/上的许多存储库都上传了这两种格式。
我想了解什么是最佳实践。一种格式优于另一种格式吗?如果.whl文件足以分发我的代码,我tar.gz也应该上传文件吗?或者还有什么我在这里完全想念的吗?
在 C 文件中包含“Python.h”:
#include <Python.h>
Run Code Online (Sandbox Code Playgroud)
给出Python.h: No such file or directory错误。我查找了其他有同样问题的人,但没有人直接回答如何在 arch Linux 上安装 python*-dev (python2 和 python3)。顺便说一句,这个答案没有 arch 安装命令。
我的makefile:
SHELL := /bin/bash
.PHONY: all
all:
pip install runcython
makecython++ stitch_wrapper.pyx "" "stitch_rects.cpp ./hungarian/hungarian.cpp"
hungarian: hungarian/hungarian.so
hungarian/hungarian.so:
cd hungarian && \
TF_INC=$$(python -c 'import tensorflow as tf; print(tf.sysconfig.get_include())') && \
if [ `uname` == Darwin ];\
then g++ -std=c++11 -shared hungarian.cc -o hungarian.so -fPIC -I $$TF_INC -undefined dynamic_lookup;\
else g++ -std=c++11 -shared hungarian.cc -o hungarian.so -fPIC -I $$TF_INC; fi
Run Code Online (Sandbox Code Playgroud)
我已经安装了
-cython
-runcython
-python-dev
-python3-dev
-cffi
Run Code Online (Sandbox Code Playgroud)
不幸的是,我继续得到错误:
pkg-config: command not found
.cpp:4:20: fatal error: Python.h: No such file or directory …Run Code Online (Sandbox Code Playgroud) 我在运行Debian Stretch的Windows 10 WSL上安装pip软件包时遇到问题。
运行时sudo pip install invoice2data,python3-pip安装后遇到以下错误。
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Failed building wheel for regex
Running setup.py clean for regex
Failed to build regex
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-2.7.13=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c regex_2/_regex.c -o build/temp.linux-x86_64-2.7/regex_2/_regex.o
regex_2/_regex.c:46:20: 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
---------------------------------------- …Run Code Online (Sandbox Code Playgroud) 我有一个简单的 dockerfile,用于在 AWS 上运行容器,但在安装时遇到了问题s3fs,这很奇怪,因为我在之前的 dockerfile 中使用了此代码段,没有出现问题。
与分布有关吗?
错误:
multidict/_multidict.c:1:10: fatal error: Python.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
Dockerfile:
FROM amazonlinux:latest
RUN yum -y install which unzip aws-cli \
&& yum install -y python3-pip python3 python3-setuptools \
&& yum install -y tar.x86_64 \
&& DEBIAN_FRONTEND=noninteractive yum install -y ksh
RUN pip3 install boto3 \
&& yum install -y gcc \
&& pip3 install s3fs
Run Code Online (Sandbox Code Playgroud)
这是输出日志:
Installing collected packages: fsspec, docutils, botocore, typing-extensions, aioitertools, wrapt, attrs, chardet, multidict, async-timeout, idna, …Run Code Online (Sandbox Code Playgroud) 我正在尝试将Python 3脚本转换为C,然后将该C文件编译为可执行文件.
我有这个简单的python脚本:
def greet(name = ""):
print("Hello {0}".format(name if len(name) > 0 else "World"))
greet("Mango")
Run Code Online (Sandbox Code Playgroud)
我使用以下命令将此脚本转换为C:
cython greet.py -o greet.c
Run Code Online (Sandbox Code Playgroud)
然后我使用以下方法编译了C文件:
cc greet.c -o greet
Run Code Online (Sandbox Code Playgroud)
在我输入最后一个命令后,我得到了错误:
致命错误:Python.h:没有终止此类文件或目录编译.
在我收到错误之后,我回过头来意识到我使用的是Python3并且我忘记了"cython"之后的"3".
所以使用以下方法重新编译python脚本:
cython3 greet.py -o greet.c
Run Code Online (Sandbox Code Playgroud)
然后尝试使用以下命令重新编译C文件:
cc greet.c -o greet
Run Code Online (Sandbox Code Playgroud)
再次失败并抛出相同的错误,所以我去搜索SO和谷歌并发现了这些问题:
这些问题中的这些答案都不起作用.
我已经确定我已经安装了所有正确依赖项的cython,apt-get install并且pip install遗憾地认为它似乎仍然不起作用.
我试图用 PIP安装噪声模块(https://pypi.org/project/noise/),但它向我展示了这个......
Collecting noise
Using cached https://files.pythonhosted.org/packages/18/29/bb830ee6d934311e17a7a4fa1368faf3e73fbb09c0d80fc44e41828df177/noise-1.2.2.tar.gz
Installing collected packages: noise
Running setup.py install for noise ... error
Complete output from command C:\Users\Zapdexio\AppData\Local\Programs\Python\Python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Zapdexio\\AppData\\Local\\Temp\\pip-install-jn9dq5g6\\noise\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Zapdexio\AppData\Local\Temp\pip-record-iqmzked2\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.7
creating build\lib.win-amd64-3.7\noise
copying perlin.py -> build\lib.win-amd64-3.7\noise
copying setup.py -> build\lib.win-amd64-3.7\noise
copying shader.py -> build\lib.win-amd64-3.7\noise
copying shader_noise.py -> build\lib.win-amd64-3.7\noise
copying test.py -> build\lib.win-amd64-3.7\noise
copying __init__.py -> build\lib.win-amd64-3.7\noise
running build_ext
building 'noise._simplex' …Run Code Online (Sandbox Code Playgroud) python ×10
pip ×4
c ×3
cython ×3
ubuntu ×2
arch ×1
docker ×1
dockerfile ×1
gcc ×1
homebrew ×1
installation ×1
linux ×1
mod-wsgi ×1
module ×1
noise ×1
pycrypto ×1
pypi ×1
python-2.7 ×1
python-3.6 ×1
python-c-api ×1
twine ×1
ubuntu-16.04 ×1