我已经在 Debian-Jessie 机器上安装了 GNS3(网络模拟器),但是当我尝试启动该程序时,出现以下错误:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
有什么想法为什么会这样吗?
我还进行了跟踪,以防有帮助:
/usr/lib$strace /usr/bin/gns3
execve("/usr/bin/gns3", ["/usr/bin/gns3"], [/* 38 vars */]) = 0
brk(NULL) = 0x1115000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe93573f000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=183999, ...}) = 0
mmap(NULL, 183999, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe935712000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0a\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=135744, ...}) = 0
mmap(NULL, 2212904, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe935301000
mprotect(0x7fe935319000, 2093056, PROT_NONE) = 0
mmap(0x7fe935518000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17000) = 0x7fe935518000
mmap(0x7fe93551a000, 13352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe93551a000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\10\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1697504, ...}) = 0
mmap(NULL, 3803552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe934f60000
mprotect(0x7fe9350f7000, 2097152, PROT_NONE) = 0
mmap(0x7fe9352f7000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x197000) = 0x7fe9352f7000
mmap(0x7fe9352fd000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7fe9352fd000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\240\r\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=14640, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe935711000
mmap(NULL, 2109680, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe934d5c000
mprotect(0x7fe934d5e000, 2097152, PROT_NONE) = 0
mmap(0x7fe934f5e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7fe934f5e000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libutil.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\16\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=10688, ...}) = 0
mmap(NULL, 2105608, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe934b59000
mprotect(0x7fe934b5b000, 2093056, PROT_NONE) = 0
mmap(0x7fe934d5a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1000) = 0x7fe934d5a000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libexpat.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0;\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=166032, ...}) = 0
mmap(NULL, 2261096, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe934930000
mprotect(0x7fe934956000, 2097152, PROT_NONE) = 0
mmap(0x7fe934b56000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26000) = 0x7fe934b56000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \"\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=109144, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe935710000
mmap(NULL, 2204200, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe934715000
mprotect(0x7fe93472f000, 2093056, PROT_NONE) = 0
mmap(0x7fe93492e000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7fe93492e000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0pU\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=1067424, ...}) = 0
mmap(NULL, 3162344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7fe934410000
mprotect(0x7fe934514000, 2093056, PROT_NONE) = 0
mmap(0x7fe934713000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x103000) = 0x7fe934713000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe93570f000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe93570e000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe93570d000
arch_prctl(ARCH_SET_FS, 0x7fe93570e700) = 0
mprotect(0x7fe9352f7000, 16384, PROT_READ) = 0
mprotect(0x7fe934713000, 4096, PROT_READ) = 0
mprotect(0x7fe93492e000, 4096, PROT_READ) = 0
mprotect(0x7fe934b56000, 8192, PROT_READ) = 0
mprotect(0x7fe934d5a000, 4096, PROT_READ) = 0
mprotect(0x7fe934f5e000, 4096, PROT_READ) = 0
mprotect(0x7fe935518000, 4096, PROT_READ) = 0
mprotect(0x8fd000, 4096, PROT_READ) = 0
mprotect(0x7fe935741000, 4096, PROT_READ) = 0
munmap(0x7fe935712000, 183999) = 0
set_tid_address(0x7fe93570e9d0) = 30088
set_robust_list(0x7fe93570e9e0, 24) = 0
rt_sigaction(SIGRTMIN, {0x7fe935306ba0, [], SA_RESTORER|SA_SIGINFO, 0x7fe935311ed0}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x7fe935306c30, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0x7fe935311ed0}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
brk(NULL) = 0x1115000
brk(0x1136000) = 0x1136000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1668976, ...}) = 0
mmap(NULL, 1668976, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fe935575000
close(3) = 0
open("/usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=26258, ...}) = 0
mmap(NULL, 26258, PROT_READ, MAP_SHARED, 3, 0) = 0x7fe935738000
close(3) = 0
futex(0x7fe9352fc8c8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
open("/dev/urandom", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_GETFD) = 0x1 (flags FD_CLOEXEC)
read(3, "\277\310\6}\261\210\337\236\5\227\353\273\201M\20x\363:\220Q\226H\251>", 24) = 24
close(3) = 0
ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe9343d0000
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe934390000
brk(0x1157000) = 0x1157000
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 7), ...}) = 0
readlink("/usr/share/gns3/gns3-gui/bin/python", "python3", 4096) = 7
readlink("/usr/share/gns3/gns3-gui/bin/python3", 0x7fffc1cc4220, 4096) = -1 EINVAL (Invalid argument)
open("/usr/share/gns3/gns3-gui/bin/pyvenv.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/gns3/gns3-gui/pyvenv.cfg", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/gns3-gui/bin/Modules/Setup", 0x7fffc1cc51b0) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/gns3-gui/bin/lib/python3.4/os.py", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/gns3-gui/bin/lib/python3.4/os.pyc", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/gns3-gui/lib/python3.4/os.py", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/gns3-gui/lib/python3.4/os.pyc", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/lib/python3.4/os.py", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/lib/python3.4/os.pyc", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/share/lib/python3.4/os.py", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/share/lib/python3.4/os.pyc", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python3.4/os.py", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python3.4/os.pyc", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python3.4/os.py", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python3.4/os.pyc", 0x7fffc1cc51a0) = -1 ENOENT (No such file or directory)
write(2, "Could not find platform independ"..., 55Could not find platform independent libraries <prefix>
) = 55
stat("/usr/share/gns3/gns3-gui/bin/pybuilddir.txt", 0x7fffc1cc51b0) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/gns3-gui/bin/lib/python3.4/lib-dynload", 0x7fffc1cc51b0) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/gns3-gui/lib/python3.4/lib-dynload", 0x7fffc1cc51b0) = -1 ENOENT (No such file or directory)
stat("/usr/share/gns3/lib/python3.4/lib-dynload", 0x7fffc1cc51b0) = -1 ENOENT (No such file or directory)
stat("/usr/share/lib/python3.4/lib-dynload", 0x7fffc1cc51b0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python3.4/lib-dynload", 0x7fffc1cc51b0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python3.4/lib-dynload", 0x7fffc1cc51b0) = -1 ENOENT (No such file or directory)
write(2, "Could not find platform dependen"..., 58Could not find platform dependent libraries <exec_prefix>
) = 58
write(2, "Consider setting $PYTHONHOME to "..., 57Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
) = 57
mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fe934350000
brk(0x1178000) = 0x1178000
sysinfo({uptime=2240881, loads=[86848, 87776, 71104], totalram=8275865600, freeram=282087424, sharedram=0, bufferram=84557824, totalswap=0, freeswap=0, procs=622, totalhigh=0, freehigh=0, mem_unit=1}) = 0
brk(0x119a000) = 0x119a000
sigaltstack({ss_sp=0x1179700, ss_flags=0, ss_size=8192}, NULL) = 0
stat("/usr/lib/python3.4/", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
stat("/usr/lib/python3.4/", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
stat("/usr/lib/python3.4/", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
open("/usr/lib/python3.4/", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
getdents(3, /* 3 entries */, 32768) = 80
getdents(3, /* 0 entries */, 32768) = 0
close(3) = 0
stat("/usr/lib/python3.4/plat-x86_64-linux-gnu", 0x7fffc1cd62c0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/python3.4", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
stat("/usr/lib/python3.4/plat-x86_64-linux-gnu", 0x7fffc1cd5ca0) = -1 ENOENT (No such file or directory)
stat("/usr/lib/lib-dynload", 0x7fffc1cd62c0) = -1 ENOENT (No such file or directory)
stat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=36864, ...}) = 0
stat("/usr/lib/lib-dynload", 0x7fffc1cd5ca0) = -1 ENOENT (No such file or directory)
write(2, "Fatal Python error: Py_Initializ"..., 69Fatal Python error: Py_Initialize: Unable to get the locale encoding
) = 69
write(2, "ImportError", 11ImportError) = 11
write(2, ": ", 2: ) = 2
write(2, "No module named 'encodings'", 27No module named 'encodings') = 27
write(2, "\n", 1
) = 1
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
tgkill(30088, 30088, SIGABRT) = 0
--- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=30088, si_uid=1000} ---
+++ killed by SIGABRT +++
Aborted
我也尝试按照以下方式设置 PYTHONHOME 但仍然没有运气:
user@station:~$which python
/usr/bin/python
user@station:~$export PYTHONHOME=/usr/bin
user@station:~$echo $PYTHONHOME
/usr/bin
user@station:~$gns3
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
答案1
尝试export PYTHONHOME=/usr/bin
。 Python 应该安装在/usr/bin
Debian 上。
如果没有,请运行which python
并使用它返回的目录:export PYTHONHOME=<directory>
编辑
也试试export PYTHONPATH=/usr/lib/python2.7
。
在执行此操作之前,请确保该目录确实存在。它会根据 python 版本而有所不同,但这应该是模块存储的位置。
更好的是,附加它而不是替换为:
export PYTHONPATH=$PYTHONPATH:/usr/lib/python2.7
答案2
我今天也遇到了同样的问题。到目前为止我还没有找到解决方案,让我告诉你我是如何解决的。
首先,根据您的发行版清除您的 gns3 安装。我使用的是 debian,所以我使用了以下命令: $sudo apt-get autoremove --purge gns3*
二、进入gns3官方网站:https://docs.gns3.com/1QXVIihk7dsOL7Xr7Bmz4zRzTsJ02wklfImGuHwTlaA4/并按照您新的 gns3 版本的安装进行操作