简体   繁体   English

Python3.7如何使用pydensecrf?

[英]How to use pydensecrf in Python3.7?

I am running the following python code我正在运行以下 python 代码

import numpy as np
import pydensecrf.densecrf as dcrf
import matplotlib.pyplot as plt

which results in这导致

    ModuleNotFoundError                       Traceback (most recent call last)
    <ipython-input-4-cbaa174fb5e7> in <module>
          1 import numpy as np
    ----> 2 import pydensecrf.densecrf as dcrf
          3 import matplotlib.pyplot as plt

ModuleNotFoundError: No module named 'pydensecrf'

I have tried installing: pip install pydensecrf But whenever I do, i get the following error我试过安装: pip install pydensecrf 但是每当我这样做时,我都会收到以下错误

C:\Users\Aparajita Das>pip install pydensecrf
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pydensecrf/
Collecting pydensecrf
  Using cached pydensecrf-1.0rc3.tar.gz (1.0 MB)
Building wheels for collected packages: pydensecrf
  Building wheel for pydensecrf (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Aparajita Das\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"'; __file__='"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\APARAJ~1\AppData\Local\Temp\pip-wheel-v3toa6sn'
       cwd: C:\Users\APARAJ~1\AppData\Local\Temp\pip-install-pqhh72by\pydensecrf\
  Complete output (44 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.7
  creating build\lib.win-amd64-3.7\pydensecrf
  copying pydensecrf\utils.py -> build\lib.win-amd64-3.7\pydensecrf
  copying pydensecrf\__init__.py -> build\lib.win-amd64-3.7\pydensecrf
  running build_ext
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\APARAJ~1\AppData\Local\Temp\pip-install-pqhh72by\pydensecrf\setup.py", line 41, in <module>
      "Topic :: Scientific/Engineering :: Artificial Intelligence",
    File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\__init__.py", line 144, in setup
      return distutils.core.setup(**attrs)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\core.py", line 148, in setup
      dist.run_commands()
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\wheel\bdist_wheel.py", line 223, in run
      self.run_command('build')
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\build.py", line 135, in run
      self.run_command(cmd_name)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
      cmd_obj.run()
    File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\command\build_ext.py", line 87, in run
      _build_ext.run(self)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\build_ext.py", line 309, in run
      force=self.force)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\ccompiler.py", line 1031, in new_compiler
      return klass(None, dry_run, force)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cygwinccompiler.py", line 285, in __init__
      CygwinCCompiler.__init__ (self, verbose, dry_run, force)
    File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cygwinccompiler.py", line 129, in __init__
      if self.ld_version >= "2.10.90":
  TypeError: '>=' not supported between instances of 'NoneType' and 'str'
  ----------------------------------------
  ERROR: Failed building wheel for pydensecrf
  Running setup.py clean for pydensecrf
Failed to build pydensecrf
Installing collected packages: pydensecrf
    Running setup.py install for pydensecrf ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Aparajita Das\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"'; __file__='"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\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\APARAJ~1\AppData\Local\Temp\pip-record-tms9_lds\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Aparajita Das\Anaconda3\Include\pydensecrf'
         cwd: C:\Users\APARAJ~1\AppData\Local\Temp\pip-install-pqhh72by\pydensecrf\
    Complete output (46 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\pydensecrf
    copying pydensecrf\utils.py -> build\lib.win-amd64-3.7\pydensecrf
    copying pydensecrf\__init__.py -> build\lib.win-amd64-3.7\pydensecrf
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\APARAJ~1\AppData\Local\Temp\pip-install-pqhh72by\pydensecrf\setup.py", line 41, in <module>
        "Topic :: Scientific/Engineering :: Artificial Intelligence",
      File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\Aparajita Das\Anaconda3\lib\site-packages\setuptools\command\build_ext.py", line 87, in run
        _build_ext.run(self)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\command\build_ext.py", line 309, in run
        force=self.force)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\ccompiler.py", line 1031, in new_compiler
        return klass(None, dry_run, force)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cygwinccompiler.py", line 285, in __init__
        CygwinCCompiler.__init__ (self, verbose, dry_run, force)
      File "C:\Users\Aparajita Das\Anaconda3\lib\distutils\cygwinccompiler.py", line 129, in __init__
        if self.ld_version >= "2.10.90":
    TypeError: '>=' not supported between instances of 'NoneType' and 'str'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Aparajita Das\Anaconda3\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\setup.py'"'"'; __file__='"'"'C:\\Users\\APARAJ~1\\AppData\\Local\\Temp\\pip-install-pqhh72by\\pydensecrf\\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\APARAJ~1\AppData\Local\Temp\pip-record-tms9_lds\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Aparajita Das\Anaconda3\Include\pydensecrf' Check the logs for full command output.

I am using Python 3.7.3 and I have cpython installed.我正在使用 Python 3.7.3 并且我安装了 cpython。 I have checked everywhere and no solution is working for me.我到处检查过,没有解决方案对我有用。 I have tried downgrading python, thinking it might work for older version using the following but it does not even downgrade it to the given version.我曾尝试降级 python,认为它可能适用于使用以下的旧版本,但它甚至不会降级到给定版本。

conda install python=3.5.0

How do I solve this?我该如何解决这个问题?

For me installation failed with error: command 'gcc' failed with exit status 1. This worked for me:对我来说,安装失败并error: command 'gcc' failed with exit status 1.这对我有用:

pip install cython
pip install git+https://github.com/lucasb-eyer/pydensecrf.git

Installing cython is the first thing you need to try out.That alone didn't work for me.Combination of both worked like a charm.安装 cython 是您需要尝试的第一件事。仅此一项对我不起作用。两者的结合就像一种魅力。

Referred to the comments at https://github.com/lucasb-eyer/pydensecrf/issues/78参考https的评论://github.com/lucasb-eyer/pydensecrf/issues/78

Step1: download package of pydensecrf compatible with python version from link https://anaconda.org/conda-forge/pydensecrf/files?version=1.0rc2&page=2 Step2: Extract the package and copy two subfolders "pydensecrf and pydensecrf-1.0rc2.dist-info" in folder "Lib" to installed folder of python (Example: C:\Python 3.6\Lib\site-packages) Step1: download package of pydensecrf compatible with python version from link https://anaconda.org/conda-forge/pydensecrf/files?version=1.0rc2&page=2 Step2: Extract the package and copy two subfolders "pydensecrf and pydensecrf-1.0rc2文件夹“Lib”中的 .dist-info" 到 python 的已安装文件夹(例如:C:\Python 3.6\Lib\site-packages)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM