在我的安装( Windows 7上的Python3.8.1)上,如果我运行以下代码:
import pkg_resources
print([d.key for d in pkg_resources.working_set if d.key[0] == "-"])
我得到以下输出:
['-fi', '-', '-.fi', '-ffi']
这些包裹以"-“开头是什么?
我补充说,在我的系统上,每次我用命令pip install --upgrade cffi升级软件包"cffi“时,我都会得到以下错误
在python中,如果我想创建一个在传递给特定函数时执行某些操作的对象,我该如何做呢?例如:
import logging
class TestObject:
def __logging__(self):
# It would check the calling function here and return something
# if it was a log function call from a logging class log function call
return 'Some text'
我想知道如何使用现有的C接口(一个头文件),并使用CFFI库在Python中实现这样的接口。
例如,我有以下头文件,interface.h
void* foo(void* value);
我想用Python实现它。我认为下面的程序可以完成工作,但它没有,它创建了函数foo,但它不能保证实现遵循在头文件中定义的结构。
import cffi
ffibuilder = cffi.FFI()
with open('interface.h') as f:
data = ''.join([line for line in f if not line.start
我正在尝试安装一个python软件(https://github.com/GuLinux/AstroPhoto-Plus),但是在日志中,我在安装之后的执行过程中得到了这个错误: Exception: Version mismatch: this is the 'cffi' package version 1.14.6, located in '/tmp/pip-build-env-kuxyuc2x/overlay/lib/python3.8/site-packages/cffi/api.py'.
When we import the top-level
我得到了下面的错误,当建立一个码头形象“对接-合成构建”。
ERROR: Couldn't connect to Docker daemon at http://127.0.0.1:2375 - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
即使我试着用"sudo",我也知道:
Building web
Step 1/8 : FROM python:3.8.3-alpine
--->
我试图用easy_install -U Scrapy安装Scrapy,但是在安装它时,它最终出现了一个奇怪的错误,“无法打开包含文件”。有人知道发生了什么事吗?这是我的全部回溯:
C:\Users\Mubashar Kamran>easy_install -U Scrapy
Searching for Scrapy
Reading https://pypi.python.org/simple/Scrapy/
Best match: scrapy 0.24.4
Processing scrapy-0.24.4-py2.7.egg
scrapy 0.24.4 is already the a
我正在尝试在我的enter code here服务器上安装paramiko模块。pip在服务器上被阻止,因此我手动复制包zips并从setup.py安装它们
当我尝试安装paramiko时,我得到
error: Could not find suitable distribution for Requirement.parse('pynacl>=1.0.1')
所以我下载了PyNaCl包,但是我得到了
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.
我正在尝试从git安装一个新的Django项目,我使用python3(版本: 3.8.5)创建了一个新的虚拟环境。当我尝试在requirements.txt中安装所需的库时,我得到cffi==1.11.5包的以下错误。 Building wheels for collected packages: cffi
Building wheel for cffi (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/jessica/Documents/FreelancePro
Mac OS Big Sur更新导致django 1.11的pip安装要求出现cffi错误。我该如何解决这个问题? Running setup.py install for cffi ... error
ERROR: Command errored out with exit status 1:
command: /Users/axil/Documents/project/projectdotcom/projectdotcomenv_v2/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '
我尝试使用Python中的CFFI包为已经存在的C代码创建一个Python接口。
我可以通过下面的编译一个C库。现在,我想让这个python库不需要对sys.path进行任何花哨的更新就可以使用。
我发现也许通过Python setup()函数创建一个发行版就可以做到这一点,我主要通过创建一个setup.py文件来完成这个任务
import os
import sys
from setuptools import setup, find_packages
os.chdir(os.path.dirname(sys.argv[0]) or ".")
setup(
na
当我试图通过pip install cryptography或从下载软件包并运行python setup.py来安装时,我会得到以下错误:
D:\Anaconda\Scripts\pip-script.py run on 02/27/14 16:13:17
Downloading/unpacking cryptography
Getting page https://pypi.python.org/simple/cryptography/
URLs to search for versions for cryptography:
* https://pypi.python.org
我正在尝试将cryptography==3.2.1安装到我的django项目中,但是我得到了这个错误
Collecting cryptography==3.2.1
Downloading cryptography-3.2.1.tar.gz (540 kB)
Installing build dependencies: started
Installing build dependencies: finished with status 'error'
ERROR: Command errored out with exit status 1:
comman
我正在尝试在我的mac上安装jupyter,但在安装时遇到错误。 用于安装的命令: pip install jupyterlab
pip install notebook 两者都给出了类似的错误。 我承认我是在测试版操作系统上,因此如果它不受支持,我不会抱怨,只是要求确保它不是一些愚蠢的用户错误。 显示的错误: Defaulting to user installation because normal site-packages is not writeable
Collecting notebook
Using cached notebook-6.1.4-py3-none-any.w
使用pip版本20.2.4、Python 3.8.2和Big Sur 11.0.1。 当我运行pip install cryptography时,我得到这个错误: Building wheels for collected packages: cffi
Building wheel for cffi (setup.py): started
Building wheel for cffi (setup.py): finished with status 'error'
ERROR: Command errored out with exit stat
我有一个C源文件/头文件,它是一个更大的项目的一部分。我想测试这作为一个单位,独立于真正的项目。虽然在C中可以通过使用不同的main()创建一个新项目来实现这一点,但我想看看是否可以使用Python (3)及其框架(例如。加快测试的构建,使用现有的报告框架等。
我当时的印象是我可以用CFFI来做这件事。下面是一个示例C文件:
// magic.c
// Implementation of magic.
int add(int a, int b)
{
return a;
}
标题:
// magic.h
// Add two numbers (where a + b is not gre
正如this popular question解释的那样,Python3中的range对象足够聪明,能够有效地测试成员资格: In [1]: 1000000000000000 in range(1000000000000001)
Out[1]: True # answer returned very quickly 然而,对于使用max和min计算range的最大值和最小值,情况并非如此,这似乎是在整个序列中迭代以找到这些值: In [2]: max(range(1000000000000001)) # don't do this
... 为range对象高效地实现这些函数