本文采用下载源码的方式安装
git clone git@github.com:mininet/mininet.git
推荐使用git协议clone,否则会有下载失败的可能
fatal: unable to access 'https://github.com/mininet/mininet/': Failed to connect to github.com port 443 after 75003 ms: Couldn't connect to server
cd mininet
git tag # list available versions
git checkout -b mininet-2.3.0 2.3.0 # 也可以选择其他版本
cd ..
创建虚环境
cd ~
virtualenv ~/.venv
source ~/.venv/bin/activate
可以把source放到 ~/.bashrc里
cat >>~/.bashrc <<EOF
# active python3 virtualenv
source ~/.venv/bin/activate
EOF
mininet/util/install.sh -a # 完整模式,也可以选择其他模式, 可以 -h 查看选项
Installing Mininet core
~/mininet ~/mininet
cc -Wall -Wextra \
-DVERSION=\"`PYTHONPATH=. python -B bin/mn --version 2>&1`\" mnexec.c -o mnexec
<command-line>: warning: missing terminating " character
mnexec.c: In function ‘main’:
<command-line>: error: missing terminating " character
mnexec.c:208:28: note: in expansion of macro ‘VERSION’
208 | printf("%s\n", VERSION);
| ^~~~~~~
mnexec.c:208:35: error: expected expression before ‘)’ token
208 | printf("%s\n", VERSION);
| ^
make: *** [Makefile:50: mnexec] Error 1
编译使用了python命令,但是环境只有python3, 没有python 命令,通过添加python软连接解决
ln -s /usr/bin/python3 /usr/bin/python
python -m pip install .
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
make: *** [Makefile:62: install] Error 1
编辑mininet/Makefile 第62行,增加 --break-system-packages
diff --git a/Makefile b/Makefile
index 0fb1f84..7934575 100644
--- a/Makefile
+++ b/Makefile
@@ -59,7 +59,7 @@ install-manpages: $(MANPAGES)
install: install-mnexec install-manpages
# This seems to work on all pip versions
$(PYTHON) -m pip uninstall -y mininet || true
- $(PYTHON) -m pip install .
+ $(PYTHON) -m pip install . --break-system-packages
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。