- 前言
- 下载速度过慢
- git clone过慢甚至无法访问
- --recursice参数导致子模块无法使用git镜像
- No module named 'openssl'
今天装网络仿真软件 ndnSIM ,我用的 Ubuntu20.04 ,装的版本是 ndnSIM2.8 ,把所有踩过的坑说一遍吧。
按照官方的教程https://ndnsim.net/current/getting-started.html, Ubuntu20.04 的安装代码应当为
sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml sudo apt install gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev python3-dev python3-gi python3-gi-cairo python3-pip python3-pygraphviz python3-pygccxml sudo pip3 install kiwi mkdir ndnSIM cd ndnSIM git clone https://github.com/named-data-ndnSIM/ns-3-dev.git ns-3 git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM cd./waf configure --enable-examples ./waf
然而遇到了很多问题,让我们跟着问题一步一步地来解决吧。
下载速度过慢一开始 apt install 下载很慢,这是因为没有使用镜像源。这里使用清华镜像源,参考链接https://blog.csdn.net/dou3516/article/details/108196179
git clone过慢甚至无法访问解决方案:使用github的镜像,如用镜像 https://github.com.cnpmjs.org/ (或者 https://hub.fastgit.org/ )代替 https://github.com/ ,示例代码:
sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml sudo apt install gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev python3-dev python3-gi python3-gi-cairo python3-pip python3-pygraphviz python3-pygccxml sudo pip3 install kiwi mkdir ndnSIM cd ndnSIM git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ns-3-dev.git ns-3 git clone https://github.com.cnpmjs.org/named-data-ndnSIM/pybindgen.git pybindgen git clone --recursive https://github.com.cnpmjs.org/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM cd–recursice参数导致子模块无法使用git镜像./waf configure --enable-examples ./waf
此时还会遇到一个问题,因为文章开头倒数第5行代码 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM 采用了 --recursive 递归下载子文件。然而递归下载时,又会使用 https://github.com/ 了,没有镜像加速,就会报这样的错
正克隆到 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/NFD'... fatal: 无法访问 'https://github.com/named-data-ndnSIM/NFD/':GnuTLS recv error (-54): Error in the pull function. fatal: 无法克隆 'https://github.com/named-data-ndnSIM/NFD' 到子模组路径 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/NFD' 克隆 'NFD' 失败。按计划重试 正克隆到 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/ndn-cxx'... fatal: 无法访问 'https://github.com/named-data-ndnSIM/ndn-cxx/':Failed to connect to github.com port 443: 拒绝连接 fatal: 无法克隆 'https://github.com/named-data-ndnSIM/ndn-cxx' 到子模组路径 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/ndn-cxx' 克隆 'ndn-cxx' 失败。按计划重试 正克隆到 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/NFD'... fatal: 无法访问 'https://github.com/named-data-ndnSIM/NFD/':Failed to connect to github.com port 443: 拒绝连接 fatal: 无法克隆 'https://github.com/named-data-ndnSIM/NFD' 到子模组路径 '/home/ndn/ndnSIM/ns-3/src/ndnSIM/NFD' 第二次尝试克隆 'NFD' 失败,退出
而实际上,子文件就只有 ndn-cxx 和 NFD ,所以我们可以手动用镜像下载。具体而言,就是把代码 git clone --recursive https://github.com/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM 更改为
git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM git clone https://github.com.cnpmjs.org/named-data-ndnSIM/NFD ns-3/src/ndnSIM/NFD git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ndn-cxx ns-3/src/ndnSIM/ndn-cxx
完整代码——
sudo apt install build-essential libsqlite3-dev libboost-all-dev libssl-dev git python3-setuptools castxml sudo apt install gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev python3-dev python3-gi python3-gi-cairo python3-pip python3-pygraphviz python3-pygccxml sudo pip3 install kiwi mkdir ndnSIM cd ndnSIM git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ns-3-dev.git ns-3 git clone https://github.com.cnpmjs.org/named-data-ndnSIM/pybindgen.git pybindgen git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ndnSIM.git ns-3/src/ndnSIM git clone https://github.com.cnpmjs.org/named-data-ndnSIM/NFD ns-3/src/ndnSIM/NFD git clone https://github.com.cnpmjs.org/named-data-ndnSIM/ndn-cxx ns-3/src/ndnSIM/ndn-cxx cdNo module named ‘openssl’./waf configure --enable-examples ./waf
这个问题很离谱,网上找不到靠谱的解决方案。按照链接http://www.04007.cn/article/478.html尝试了,然而 import OpenSSL 和 import ssl 都可以,就是 import openssl 搞不定。报错如下
Traceback (most recent call last):
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/scripting.py", line 119, in waf_entry_point
run_commands()
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/scripting.py", line 178, in run_commands
parse_options()
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/scripting.py", line 158, in parse_options
ctx.execute()
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Options.py", line 198, in execute
super(OptionsContext,self).execute()
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 85, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
user_function(self)
File "/home/ndn/ndnSIM/ns-3/wscript", line 256, in options
opt.recurse('src')
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
user_function(self)
File "/home/ndn/ndnSIM/ns-3/src/wscript", line 51, in options
opt.recurse(module, mandatory=False)
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
user_function(self)
File "/home/ndn/ndnSIM/ns-3/src/ndnSIM/wscript", line 20, in options
opt.load(['doxygen', 'sphinx_build', 'compiler-features', 'sqlite3', 'openssl'],
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 80, in load
module=load_tool(t,path,with_sys_path=with_sys_path)
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 373, in load_tool
__import__(tool)
ModuleNotFoundError: No module named 'openssl'
查看了下 OpenSSL 的位置,原来在 ~/anaconda3/lib/python3.8/site-packages/OpenSSL 。虽然不知道OpenSSL和openssl是不是一个玩意,但实在是没有别的办法了,只能自欺欺人改名了。
cp -r ~/anaconda3/lib/python3.8/site-packages/OpenSSL ~/anaconda3/lib/python3.8/site-packages/openssl
然后还是失败,报错信息如下
Traceback (most recent call last):
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/scripting.py", line 119, in waf_entry_point
run_commands()
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/scripting.py", line 182, in run_commands
ctx=run_command(cmd_name)
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/scripting.py", line 173, in run_command
ctx.execute()
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Configure.py", line 85, in execute
super(ConfigurationContext,self).execute()
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 85, in execute
self.recurse([os.path.dirname(g_module.root_path)])
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
user_function(self)
File "/home/ndn/ndnSIM/ns-3/wscript", line 491, in configure
conf.recurse('src')
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
user_function(self)
File "/home/ndn/ndnSIM/ns-3/src/wscript", line 59, in configure
conf.recurse(module, mandatory=False)
File "/home/ndn/ndnSIM/ns-3/.waf3-2.0.18-ff4ae9f5cc05353d3dc3aeff8854ae69/waflib/Context.py", line 126, in recurse
user_function(self)
File "/home/ndn/ndnSIM/ns-3/src/ndnSIM/wscript", line 33, in configure
conf.check_openssl(mandatory=True, use='OPENSSL', atleast_version=0x10001000)
AttributeError: 'ConfigurationContext' object has no attribute 'check_openssl'
在root用户目录下执行 grep -rl "check_openssl" ./ ,找不到 check_openssl 函数在哪,无奈之下,只能掩耳盗铃,注释掉 /home/ndn/ndnSIM/ns-3/src/ndnSIM/wscript 的 conf.check_openssl(mandatory=True, use='OPENSSL', atleast_version=0x10001000) 。
然后还遇到了一顿问题,我选择了放弃,并且按照上述流程,新建了一个叫做 newndnSIM 的文件夹,然后重新执行了那一串 git clone ,然后莫名其妙地编译成功了。我也懒得纠结到底是啥原因了,能用就行。



