Ubuntu22.04安装NanoTCAD ViDES时的依赖缺失与编译错误求助
Ubuntu22.04安装NanoTCAD ViDES时的依赖缺失与编译错误求助
问题描述
我在科研工作中尝试安装NanoTCAD ViDES,执行安装脚本时遇到了一系列错误,终端输出如下:
laptop@LAPTOP-EHGAEMR1:~$ cd pyViDES laptop@LAPTOP-EHGAEMR1:~/pyViDES$ sudo ./install.sh [sudo] password for laptop: sudo: unable to execute ./install.sh: No such file or directory laptop@LAPTOP-EHGAEMR1:~/pyViDES$ sudo bash install.sh Compiling NANOTCAD ViDES module for python Traceback (most recent call last): File "./configure.py", line 3, in <module> import numpy ImportError: No module named numpy gcc -fPIC -O3 -I/usr/include/python2.6 -I/usr/lib/pymodules/python2.6/numpy/core/include/numpy -c NanoTCAD_ViDESmod.c NanoTCAD_ViDESmod.c:1:10: fatal error: Python.h: No such file or directory 1 | #include "Python.h" | ^~~~~~~~~~ compilation terminated. make: *** [Makefile:48: NanoTCAD_ViDESmod.o] Error 1 gcc -fPIC -O3 -I/usr/include/python2.6 -I/usr/lib/pymodules/python2.6/numpy/core/include/numpy -c NanoTCAD_ViDESmod.c NanoTCAD_ViDESmod.c:1:10: fatal error: Python.h: No such file or directory 1 | #include "Python.h" | ^~~~~~~~~~ compilation terminated. make: *** [Makefile:48: NanoTCAD_ViDESmod.o] Error 1 laptop@LAPTOP-EHGAEMR1:~/pyViDES$
我当前使用的是Ubuntu22.04,Python版本为3.10,网上搜索后没找到可行的解决方案,希望有人能帮忙解决这个问题。
解决方案
看起来你遇到的核心问题是Python版本不兼容和依赖包缺失——NanoTCAD的安装脚本默认指向了Python2.6,但你用的是Ubuntu22.04自带的Python3.10,咱们一步步来修复:
安装Python3版本的依赖包
先解决numpy缺失的问题,直接安装Python3适配的numpy:sudo apt update && sudo apt install python3-numpy然后安装Python开发包(解决
Python.h找不到的编译错误),对应Python3.10的版本:sudo apt install python3.10-dev修改安装脚本的Python版本指向
安装脚本和配置文件默认调用Python2,需要改成Python3:- 优先用Python3直接执行配置脚本,替代原来的调用逻辑:
sudo python3 configure.py - 编辑
install.sh脚本,把里面所有的python替换成python3,同时把编译参数里的Python2路径替换成Python3.10的路径:
比如把-I/usr/include/python2.6改成-I/usr/include/python3.10,把-I/usr/lib/pymodules/python2.6/numpy/core/include/numpy改成-I/usr/lib/python3/dist-packages/numpy/core/include/numpy(如果不确定numpy的具体路径,可以用pip3 show numpy查看Location字段,再拼接上/numpy/core/include/numpy)
- 优先用Python3直接执行配置脚本,替代原来的调用逻辑:
重新执行安装脚本
完成上述修改后,再重新运行安装命令:sudo bash install.sh
如果还是遇到问题,可以先确认python3 --version的输出是否为3.10,确保当前Python3环境指向正确版本。
备注:内容来源于stack exchange,提问作者nattakorn borwornpornmetee Mo
相关产品推荐
相关产品推荐

