小编Ant*_*ile的帖子

无法使用 pip 在 python 3 中安装 GDAL(clang 失败,退出状态为 1)

sudo pip3.4 install gdal从终端(Mac OS X Mavericks)运行后,我收到一条错误消息,指出'col_port.h'未找到该文件并显示以下错误:(command '/user/bin/clang/ failed with exit status 1完整消息如下)。

我有 gdal 1.11(从 kingchaos.com 下载的完整框架版本)和最新版本的 Xcode 命令行工具 -Apple LLVM version 5.1 (clang-503.0.40)(基于 LLVM 3.4svn)


这是我运行sudo pip3.4 install gdal命令后得到的错误:

/usr/bin/clang -fno-strict-aliasing -Werror=declaration-after-statement -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/Library/Frameworks/Python.framework/Versions/3.4/include/python3.4m -I/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/numpy/core/include -I/Library/Frameworks/GDAL.framework/Versions/1.11/include -c extensions/gdal_wrap.cpp -o build/temp.macosx-10.6-intel-3.4/extensions/gdal_wrap.o
extensions/gdal_wrap.cpp:2230:11: warning: explicitly assigning a variable of type 'int' to itself [-Wself-assign]
                    res = SWIG_AddCast(res); …
Run Code Online (Sandbox Code Playgroud)

clang gdal python-3.4

6
推荐指数
1
解决办法
2864
查看次数

ModuleNotFoundError:没有名为“ BaseHTTPServer”的模块

因此,我尝试在线上有关如何使用web.py的教程,并且安装了它,但不幸的是,使用这段代码会产生讨厌的错误。我的代码...

import web

urls = (
    '/(.*)', 'index'
)

app = web.application(urls, globals())


class index:
    def GET(self, name):
        return "Hello", name, '. How are you today?'

if __name__== "__main__":
    app.run()
Run Code Online (Sandbox Code Playgroud)

我的错误:

C:\Users\User\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/User/PycharmProjects/Webprojects/main.py

Traceback (most recent call last):
  File "C:/Users/User/PycharmProjects/Webprojects/main.py", line 15, in <module>
    app.run()
  File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web\application.py", line 312, in run
    return wsgi.runwsgi(self.wsgifunc(*middleware))
  File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web\wsgi.py", line 59, in runwsgi
    return httpserver.runsimple(func, server_addr)
  File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web\httpserver.py", line 154, in runsimple
    func = LogMiddleware(func)
  File "C:\Users\User\AppData\Local\Programs\Python\Python36-32\lib\site-packages\web\httpserver.py", line 296, in __init__
    from BaseHTTPServer import …
Run Code Online (Sandbox Code Playgroud)

python web.py python-3.6

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

忽略文件夹的特定 flake8 规则

我正在使用flake8flake8-docstrings以及flake8我们项目中的许多其他插件

我只想禁用flake8-docstrings我们的test文件夹。

我想避免运行 flake8 两次,因为这意味着运行 flake8 不再是直截了当的flake8 .。这不仅会扰乱我的 ide 设置,还会成为我项目中其他开发人员无法运行flake8.

有没有办法配置 flake8 以排除特定文件夹的特定规则?

python python-3.x flake8

6
推荐指数
1
解决办法
1062
查看次数

pytest 钩子可以使用夹具吗?

我知道夹具可以使用其他夹具,但是钩子可以使用夹具吗?我在网上搜索了很多,但没有得到任何帮助。如果我在这里做错了,有人可以指出吗?

#conftest.py

@pytest.fixture()
def json_loader(request):   
    """Loads the data from given JSON file"""
    def _loader(filename):
        import json
        with open(filename, 'r') as f:
            data = json.load(f)
        return data
    return _loader



def pytest_runtest_setup(item,json_loader): #hook fails to use json_loader
    data = json_loader("some_file.json") 
    print(data) 
    #do something useful here with data
Run Code Online (Sandbox Code Playgroud)

运行时出现以下错误。

pluggy.manager.PluginValidationError: 插件 'C:\some_path\conftest.py' for hook 'pytest_runtest_setup' hookimpl 定义:pytest_runtest_setup(item, json_loader) Argument(s) {'json_loader'} 在 hookimpl 中声明但找不到在钩子规范中

即使我没有将 json_loader 作为 arg 传递给 pytest_runtest_setup(),我也会收到一条错误消息,指出“Fixture“json_loader”被直接调用。Fixtures 并不意味着被直接调用”

python pytest

6
推荐指数
1
解决办法
2973
查看次数

包需要不同的 Python: 2.7.17 not in '&gt;=3.6.1' while setting up pre-commit

我克隆了一个存储库,安装了 pre-commit 并且是第一次提交 这是实际安装和设置预提交包的时间。我遇到了以下问题。

[INFO] Installing environment for https://github.com/asottile/seed-isort-config.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/home/roopak/.cache/pre-commit/repokb2ckm/py_env-python2.7/bin/python', u'/home/roopak/.cache/pre-commit/repokb2ckm/py_env-python2.7/bin/pip', 'install', '.')
return code: 1
expected return code: 0
stdout:
    Processing /home/roopak/.cache/pre-commit/repokb2ckm

stderr:
    DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop …
Run Code Online (Sandbox Code Playgroud)

python git pre-commit pre-commit-hook pre-commit.com

6
推荐指数
1
解决办法
8879
查看次数

仅在某些分支上运行预提交

我正在寻找一个配置,.pre-commit-config.yaml以排除在某些分支上运行预提交,或者只在某些分支上运行它。我不知道这个功能是否没有实现,或者我是否在文档中遗漏了它。

谢谢!

git pre-commit pre-commit-hook pre-commit.com

6
推荐指数
1
解决办法
256
查看次数

带有 git 预提交钩子的 CalledProcessError

我在安装预提交挂钩时遇到了障碍。根据下面的错误,挂钩安装在目录中找不到 python exe C:\\\\Users\\\\dangler\\\\.cache\\\\pre-commit\\\\repoith5dg7x\\\\py_env-default\\\\Scripts\\\\python.EXE(该文件夹中不存在 python.EXE...应该吗?)。我\xe2\x80\x99在过去的几个小时里一直在尝试解决它,但没有成功。希望有一个解决方案,也许我已经搜索了错误的地方。

\n
(fiddle-env) PS C:\\Users\\dangler\\Documents\\projects\\fiddle> pre-commit clean\n(fiddle-env) PS C:\\Users\\dangler\\Documents\\projects\\fiddle> pre-commit install\n(fiddle-env) PS C:\\Users\\dangler\\Documents\\projects\\fiddle> git commit -am "README file with links"\n[INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.\n[INFO] Once installed this environment will be reused.\n[INFO] This may take a few minutes...\nAn unexpected error has occurred: CalledProcessError: command: ('C:\\\\Users\\\\dangler\\\\.cache\\\\pre-commit\\\\repookmqanwy\\\\py_env-default\\\\Scripts\\\\python.EXE', '-mpip', 'install', '.')\nreturn code: 3221225781\nexpected return code: 0\nstdout: (none)\nstderr: (none)\nCheck the log at C:\\Users\\dangler\\.cache\\pre-commit\\pre-commit.log\n
Run Code Online (Sandbox Code Playgroud)\n

.pre-commit-config.yml文件是这样的:

\n
repos:\n-   repo: https://github.com/pre-commit/pre-commit-hooks\n    rev: v2.4.0\n    hooks:\n        -   id: double-quote-string-fixer\n        -   id: check-added-large-files\n …
Run Code Online (Sandbox Code Playgroud)

git pre-commit pre-commit-hook conda pre-commit.com

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

env: python3.9: 没有这样的文件或目录

我有一些 python 代码格式化程序作为 git 预提交挂钩,并且我已将我的 python 版本更改为

brew list | grep python
python@3.7
python@3.9

brew unlink python@3.7
brew unlink python@3.9
brew link python@3.7

python -V
Python 3.7.9
Run Code Online (Sandbox Code Playgroud)

并且知道似乎有些东西被破坏了,并且在 git commit 上我得到了env: python3.9: No such file or directory,那么是什么env?以及我如何编辑它以使用python@3.7

python macos homebrew pre-commit pre-commit.com

6
推荐指数
1
解决办法
9934
查看次数

已卸载的预提交阻止“git commit”(pipenv)

我最近从我的环境中卸载了预提交。我在 pipelinev 中执行了以下操作:

pipenv --rm
<deleted Pipfile and Pipfile.lock>
pipenv install -r requirements.txt 
Run Code Online (Sandbox Code Playgroud)

我确保预提交模块不再位于requirements.txt 中。当我进行 git 提交时,我得到:

~/my_project/.venv/bin/python: No module named pre_commit
Run Code Online (Sandbox Code Playgroud)

这阻止了我提交,而且我不知道这是从哪里来的,因为未安装预提交。此外,指定的回溯路径指向 python 而不是 python3。我缺少什么?

pre-commit pre-commit-hook python-3.x pipenv pre-commit.com

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

Conda 和预提交,错误:未为“请求”安装库存根(或与 Python 3.10 不兼容)

错误信息

在使用 conda 环境时,pre-commit我收到错误:

error: Library stubs not installed for "requests" (or incompatible with Python 3.10)
Run Code Online (Sandbox Code Playgroud)

完整的错误消息是:

rc/export_data/plantuml_get_package.py:69: error: Library stubs not installed for "requests" (or incompatible with Python 3.10)
src/export_data/plantuml_get_package.py:69: note: Hint: "python3 -m pip install types-requests"
src/export_data/plantuml_get_package.py:69: note: (or run "mypy --install-types" to install all missing stub packages)
src/export_data/plantuml_get_package.py:69: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 24 source files)
Run Code Online (Sandbox Code Playgroud)

错误消息中给出了默认的解决方案:

mypy --install-types
Run Code Online (Sandbox Code Playgroud)

然而,要求已经满足:

Installing missing stub packages:
/usr/bin/python3 -m pip install types-requests

Install? …
Run Code Online (Sandbox Code Playgroud)

typing pre-commit conda mypy pre-commit.com

6
推荐指数
1
解决办法
7799
查看次数