相关疑难解决方法(0)

使用Python创建加密的ZIP文件

我在Python 2.5中使用ZipFile创建一个ZIP文件,它到目前为止工作正常:

import zipfile, os

locfile = "test.txt"
loczip = os.path.splitext (locfile)[0] + ".zip"
zip = zipfile.ZipFile (loczip, "w")
zip.write (locfile)
zip.close()
Run Code Online (Sandbox Code Playgroud)

但我找不到如何加密ZIP文件中的文件.我可以使用系统并调用PKZIP -s,但我想必须有更"Pythonic"的方式.我正在寻找一个开源解决方案.

python zip

32
推荐指数
5
解决办法
3万
查看次数

我无法在python上安装pyaudio吗?怎么做?

我有一台Windows 10 pc,我想安装pyaudio以与我的chatbot一起使用,由chatterbot提供支持,我尝试使用2种不同的方式来安装pyaudio。方法是在命令提示符下编写

python -m pip install PyAudio
Run Code Online (Sandbox Code Playgroud)

结果是:

   C:\Users\Waaberi>python -m pip install PyAudio
Collecting PyAudio
  Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: PyAudio
  Running setup.py install for PyAudio ... error
    Complete output from command C:\Users\Waaberi\AppData\Local\Programs\Python\Python37-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\Waaberi\\AppData\\Local\\Temp\\pip-install-e5le61j0\\PyAudio\\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\Waaberi\AppData\Local\Temp\pip-record-adj3zivl\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.7
    copying src\pyaudio.py -> build\lib.win32-3.7
    running build_ext
    building '_portaudio' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft …
Run Code Online (Sandbox Code Playgroud)

python voice-recognition pyaudio python-3.x chatterbot

11
推荐指数
7
解决办法
6万
查看次数

无法构建 ta-lib 错误:无法为 ta-lib 构建轮子,这是安装基于 pyproject.toml 的项目所必需的

我在 pip 安装 ta-lib 时遇到以下错误。\n我使用了命令:

\n
!pip install ta-lib\n
Run Code Online (Sandbox Code Playgroud)\n

请为我提供解决方案。

\n
    Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/\nCollecting ta-lib\n  Using cached TA-Lib-0.4.25.tar.gz (271 kB)\n  Installing build dependencies ... done\n  Getting requirements to build wheel ... done\n  Installing backend dependencies ... done\n  Preparing metadata (pyproject.toml) ... done\nRequirement already satisfied: numpy in /usr/local/lib/python3.8/dist-packages (from ta-lib) (1.21.6)\nBuilding wheels for collected packages: ta-lib\n  error: subprocess-exited-with-error\n  \n  \xc3\x97 Building wheel for ta-lib (pyproject.toml) did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> See above for output.\n …
Run Code Online (Sandbox Code Playgroud)

python artificial-intelligence algorithmic-trading technical-indicator

9
推荐指数
3
解决办法
7万
查看次数

错误:命令“C:\\ Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe”失败,退出状态为 2

嗨,所以我试图pip install python-ldap使用我的 git bash,但起初它告诉我我没有,cl.exe所以我下载了 Visual Studio C++ 包,现在它显示了这个错误

 error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
Run Code Online (Sandbox Code Playgroud)

我从来没有用 C++ 编码,所以我不确定错误是什么。我也下载了 C++ 的 CLI 工具,我不认为这是因为cl.exe它在找到它后不在路径中。任何见解?

c++ pip visual-studio visual-c++

8
推荐指数
3
解决办法
7万
查看次数

无法在Windows Python 3.5上安装Levenshtein distance软件包

我需要安装python Levenshtein距离包才能使用这个库.不幸的是,我无法成功安装它.我通常用pip安装库.但是,这次我得到error: [WinError 2] The system cannot find the file specified了之前从未发生过的事情(安装库时).我试图使用它安装它,python setup.py install但我得到完全相同的错误.这是我从控制台获得的输出.

C:\Users\my_user\Anaconda3\Lib\site-packages\python-Levenshtein-0.10.2>python setup.py install
running install
running bdist_egg
running egg_info
writing dependency_links to python_Levenshtein.egg-info\dependency_links.txt
writing namespace_packages to python_Levenshtein.egg-info\namespace_packages.txt
writing entry points to python_Levenshtein.egg-info\entry_points.txt
writing python_Levenshtein.egg-info\PKG-INFO
writing top-level names to python_Levenshtein.egg-info\top_level.txt
writing requirements to python_Levenshtein.egg-info\requires.txt
reading manifest file 'python_Levenshtein.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*' under directory 'docs'
warning: no previously-included files matching '*pyc' found anywhere in …
Run Code Online (Sandbox Code Playgroud)

pip python-3.x levenshtein-distance

7
推荐指数
5
解决办法
2万
查看次数

使用 pip 安装 lxml 失败

我正在尝试使用 pip 安装 lxml。我有 Windows 11 和 Python 版本 python-3.10.2-amd64。我也在使用 Visual Studio Code (VSC)。我意识到我需要 lxml 从我的 VSC 终端中的错误消息:

\n
Traceback (most recent call last):\nFile "Vegas.py", line 13, in <module>\nsoup = BeautifulSoup(html_text, \'lxml\')\nFile "/usr/lib/python3.6/site-packages/bs4/__init__.py", line 248, in \n__init__\n% ",".join(features))\nbs4.FeatureNotFound: Couldn\'t find a tree builder with the features you \nrequested: lxml. Do you need to install a parser library?\n
Run Code Online (Sandbox Code Playgroud)\n

从那里,我尝试使用 VSC 终端中的命令安装 lxml:

\n
pip install lxml\n
Run Code Online (Sandbox Code Playgroud)\n

我收到此错误消息:

\n
Collecting lxml\n  Using cached lxml-4.7.1.tar.gz (3.2 MB)\n  Preparing metadata (setup.py) ... …
Run Code Online (Sandbox Code Playgroud)

python lxml python-wheel

6
推荐指数
2
解决办法
3万
查看次数

如何将 setup.py 替换为 pyproject.toml 以获取本机 C 构建依赖项?

我遇到了这个小项目,用于创建要在 python 中使用的Black-Scholes函数的 C 编译版本。

\n

尽管示例代码似乎已于今年 7 月发布,但setup.py构建的使用类型似乎已在旧版构建之外被弃用。任何编译失败,首先抱怨缺少MS C++ 14编译器(这不是真的),然后进一步调查,似乎表明 setup.py 不能再使用。

\n

问:如何将其转换setup.py为有效pyproject.toml文件?

\n
from setuptools import setup, Extension\n\next = Extension(\'bs\', sources=[\'black_scholes/bs.c\'])\n\nsetup(\n    name="black_scholes",\n    version="0.0.1",\n    description="European Options Pricing Library",\n    packages=[\'black_scholes\'],\n    ext_modules=[ext]\n)\n
Run Code Online (Sandbox Code Playgroud)\n

从有点模糊的网站(上面),我创建了以下树结构。

\n
$ tree -L 3 ./\n./\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 black_scholes\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 black_scholes\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Makefile\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 bs.c\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pyproject.toml\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 setup.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 README.md\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 bs_test.py\n
Run Code Online (Sandbox Code Playgroud)\n

可能相关的问题:

\n

python compilation setup.py pyproject.toml

4
推荐指数
1
解决办法
3832
查看次数

错误:扭曲 iocp 支持的构建轮失败

错误图像

\n

我试图安装 daphne===4.0.0 但我不断收到此错误,

\n
ERROR: Failed building wheel for twisted-iocpsupport\n\n    Building wheels for collected packages: twisted-iocpsupport\n  Building wheel for twisted-iocpsupport (pyproject.toml) ... error\n  error: subprocess-exited-with-error\n\n  \xc3\x97 Building wheel for twisted-iocpsupport (pyproject.toml) did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [5 lines of output]\n      running bdist_wheel\n      running build\n      running build_ext\n      building \'twisted_iocpsupport.iocpsupport\' extension\n      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/\n      [end of output]\n\n  note: This error originates from a …
Run Code Online (Sandbox Code Playgroud)

python django django-rest-framework docker

4
推荐指数
1
解决办法
1万
查看次数