pip install cocotb 要求我安装 Visual C++ 编译器

pip install cocotb ask me for visual C++ compiler installation

我跟着 cocotb officials instructions 使用 miniconda3 在 windows 上安装了软件包,并且 :

conda install -c msys2 m2-base m2-make

但我因这个错误而被阻止:

(base) PS C:\Users\me> pip install cocotb
Collecting cocotb
  Using cached cocotb-1.6.2.tar.gz (209 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: cocotb
  Building wheel for cocotb (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for cocotb (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [86 lines of output]
      Modelsim/Questa executable (vdbg) executable not found. No FLI interface will be available.
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.9
      creating build\lib.win-amd64-3.9\cocotb
      copying cocotb\ANSI.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\binary.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\clock.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\config.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\decorators.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\handle.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\ipython_support.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\log.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\memdebug.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\outcomes.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\queue.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\regression.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\result.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\scheduler.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\triggers.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\utils.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\wavedrom.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\xunit_reporter.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\_py_compat.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\_sim_versions.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\_version.py -> build\lib.win-amd64-3.9\cocotb
      copying cocotb\__init__.py -> build\lib.win-amd64-3.9\cocotb
      creating build\lib.win-amd64-3.9\pygpi
      copying pygpi\entry.py -> build\lib.win-amd64-3.9\pygpi
      copying pygpi\__init__.py -> build\lib.win-amd64-3.9\pygpi
      creating build\lib.win-amd64-3.9\cocotb\types
      copying cocotb\types\array.py -> build\lib.win-amd64-3.9\cocotb\types
      copying cocotb\types\logic.py -> build\lib.win-amd64-3.9\cocotb\types
      copying cocotb\types\logic_array.py -> build\lib.win-amd64-3.9\cocotb\types
      copying cocotb\types\range.py -> build\lib.win-amd64-3.9\cocotb\types
      copying cocotb\types\__init__.py -> build\lib.win-amd64-3.9\cocotb\types
      creating build\lib.win-amd64-3.9\cocotb\_vendor
      copying cocotb\_vendor\distutils_version.py -> build\lib.win-amd64-3.9\cocotb\_vendor
      copying cocotb\_vendor\__init__.py -> build\lib.win-amd64-3.9\cocotb\_vendor
      creating build\lib.win-amd64-3.9\cocotb\_vendor\find_libpython
      copying cocotb\_vendor\find_libpython\_version.py -> build\lib.win-amd64-3.9\cocotb\_vendor\find_libpython
      copying cocotb\_vendor\find_libpython\__init__.py -> build\lib.win-amd64-3.9\cocotb\_vendor\find_libpython
      copying cocotb\_vendor\find_libpython\__main__.py -> build\lib.win-amd64-3.9\cocotb\_vendor\find_libpython
      creating build\lib.win-amd64-3.9\cocotb\share
      creating build\lib.win-amd64-3.9\cocotb\share\makefiles
      copying cocotb\share\makefiles\Makefile.deprecations -> build\lib.win-amd64-3.9\cocotb\share\makefiles
      copying cocotb\share\makefiles\Makefile.inc -> build\lib.win-amd64-3.9\cocotb\share\makefiles
      copying cocotb\share\makefiles\Makefile.sim -> build\lib.win-amd64-3.9\cocotb\share\makefiles
      creating build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.activehdl -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.cvc -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.ghdl -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.icarus -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.ius -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.modelsim -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.questa -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.riviera -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.vcs -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.verilator -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      copying cocotb\share\makefiles\simulators\Makefile.xcelium -> build\lib.win-amd64-3.9\cocotb\share\makefiles\simulators
      creating build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\cocotb_utils.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\embed.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\exports.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\gpi.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\gpi_logging.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\py_gpi_logging.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\sv_vpi_user.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\vhpi_user.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\vhpi_user_ext.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\vpi_user.h -> build\lib.win-amd64-3.9\cocotb\share\include
      copying cocotb\share\include\vpi_user_ext.h -> build\lib.win-amd64-3.9\cocotb\share\include
      creating build\lib.win-amd64-3.9\cocotb\share\def
      copying cocotb\share\def\.gitignore -> build\lib.win-amd64-3.9\cocotb\share\def
      copying cocotb\share\def\aldec.def -> build\lib.win-amd64-3.9\cocotb\share\def
      copying cocotb\share\def\ghdl.def -> build\lib.win-amd64-3.9\cocotb\share\def
      copying cocotb\share\def\icarus.def -> build\lib.win-amd64-3.9\cocotb\share\def
      copying cocotb\share\def\modelsim.def -> build\lib.win-amd64-3.9\cocotb\share\def
      copying cocotb\share\def\README.md -> build\lib.win-amd64-3.9\cocotb\share\def
      creating build\lib.win-amd64-3.9\cocotb\share\lib
      creating build\lib.win-amd64-3.9\cocotb\share\lib\verilator
      copying cocotb\share\lib\verilator\verilator.cpp -> build\lib.win-amd64-3.9\cocotb\share\lib\verilator
      running build_ext
      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/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cocotb
Failed to build cocotb
ERROR: Could not build wheels for cocotb, which is required to install pyproject.toml-based projects
(base) PS C:\Users\me>

我尝试使用全局选项:

pip install --global-option build_ext --global-option --compiler=mingw32 cocotb

完全相同的错误。

这似乎是验证器安装错误。我不需要 verilator,也许可以选择不安装它?

我终于在 msys2 上按照以下步骤安装了 cocotb。

  • 下载并安装msys2
  • 更新 msys2 :
$ pacman -Syu
[close then re-launch terminal]
$ pacman -Su
  • 安装 Gcc 和 git
$ pacman -S –needed base-devel mingw-w64-x86_64-toolchain
$ pacman -S git
  • 安装 GHDL
$ pacman -S mingw-w64-x86_64-ghdl-llvm
  • 安装 gtkwave
$ pacman -S mingw-w64-x86_64-gtkwave
  • 安装python3
$ pacman -S mingw-w64-x86_64-python-scipy mingw-w64-x86_64-python-matplotlib mingw-w64-x86_64-python-numpy
$ pacman -S --needed make mingw-w64-x86_64-gcc mingw-w64-x86_64-python3-pip mingw-w64-x86_64-python3-setuptools mingw-w64-x86_64-python3-wheel
  • 关闭终端,然后从 windows 开始菜单打开 «MSYS2 MinGW 64-bit»。
  • 最后用 pip install 安装 cocotb :
$ pip install --no-build-isolation cocotb
$ pip install --no-build-isolation pytest
$ pip install --no-build-isolation cocotbext-axi
  • 然后欣赏古典cocotb makefile to simulate VHDL with GHDL. And visualize vcd traces with gtkwave.

我在其他 windows 计算机上成功测试了此程序。