我正在使用CocoTB测试我的高密度脂蛋白设计,但据我所知,它可以与python2.7或python3一起使用。
在setup.py配置文件中,我可以看到两者都受到支持:
[...]
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
[...]在(examples/endian_swapper/tests/test_endian_swapper.py),测试endian_swapper中,如果我修改测试脚本以查看使用哪个版本:
@cocotb.test()
def wavedrom_test(dut):
"""
Generate a JSON wavedrom diagram of a trace and save it to wavedrom.json
"""
print("Python version used {}".format(sys.version_info))我可以看到python2.7是使用make命令启动测试时使用的:
Python version used sys.version_info(major=2, minor=7, micro=9, releaselevel='final', serial=0)我的python3可执行文件名为..。实际上是python3 (debian)。是否有一种规范的方法来强迫cocotb使用python3而不是python2?
发布于 2019-10-08 13:27:41
我找到了一个合适的方法。
首先,在官方网站上下载最后一个版本的python:
$ wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tar.xz然后将其解压并配置为选项--启用共享。
$ tar -Jxvf Python-3.7.4.tar.xz
$ cd Python-3.7.4
$ ./configure --enable-shared
$ make
$ sudo make install安装完毕后,转到cocotb测试目录,然后安装虚拟环境:
$ export LD_LIBRARY_PATH=/usr/local/lib
$ virtualenv --python=/usr/local/bin/python3.7 envp37
$ source envp37/bin/activate
$ python -m pip install cocotb然后,您可以使用传统的make启动您的cocotb测试环境:
$ make使用以下方法消除python环境:
$ deactivate发布于 2019-04-01 08:08:09
我在linuxconfig.org上找到了解决方案,多亏了马佩克。但这不是我想要的。
别名解决方案对我不起作用。更新-替代工作,但只与官方的python3安装在debian上。我不能使用手动安装的替代(3.7)。
$ sudo update-alternatives --config python
There are 3 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/python3.7 2 auto mode
1 /usr/bin/python2.7 0 manual mode
2 /usr/bin/python3.4 1 manual mode
* 3 /usr/bin/python3.7 2 manual mode
Press enter to keep the current choice[*], or type selection number: 3
$ make clean;make
0.00ns INFO Running on Icarus Verilog version 11.0 (devel)
0.00ns INFO Python interpreter initialised and cocotb loaded!
0.00ns INFO Running tests with Cocotb v1.0.1 from /opt/cocotb
0.00ns INFO Seeding Python random module with 1554105931
0.00ns INFO Found test test_ttl.ttl_test
0.00ns INFO Running test 1/1: ttl_test
0.00ns INFO Starting test: "ttl_test"
Description: simple ttl test function
[...]
3.4.2 (default, Feb 7 2019, 06:11:23)
[...]https://stackoverflow.com/questions/55380437
复制相似问题