GNS3 / gns3-server

GNS3 server
GNU General Public License v3.0
811 stars 263 forks source link

AttributeError: 'module' object has no attribute 'net_if_addrs' #361

Closed AJNOURI closed 8 years ago

AJNOURI commented 9 years ago

Environement:

Distributor ID: Ubuntu
Description:    Ubuntu 14.04.3 LTS
Release:    14.04
Codename:   trusty

Linux gns3-iouvm 3.13.0-66-generic #108-Ubuntu 
SMP Wed Oct 7 15:20:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Running GNS3 version 1.4.0rc1 on Linux (64-bit) with Python 3.4.3 Qt 5.2.1.

When I add a cloud, I get the following error: enter image description here

=> Warning: Cloud 1: Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/gns3server/web/route.py", line 179, in control_schema
    yield from func(request, response)
  File "/usr/lib/python3.4/asyncio/coroutines.py", line 141, in coro
    res = func(*args, **kw)
  File "/usr/local/lib/python3.4/dist-packages/gns3server/handlers/api/network_handler.py", line 52, in network_interfaces
    network_interfaces = interfaces()
  File "/usr/local/lib/python3.4/dist-packages/gns3server/utils/interfaces.py", line 146, in interfaces
    for interface in sorted(psutil.net_if_addrs().keys()):
AttributeError: 'module' object has no attribute 'net_if_addrs'

The same from python console:

>>> import util
>>> psutil.net_if_addrs()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'net_if_addrs'
>>> 

According to psutils repository https://github.com/giampaolo/psutil/issues/626 Looks like method not available?

dir(psutil) ['AccessDenied', 'BOOT_TIME', 'CONN_CLOSE', 'CONN_CLOSE_WAIT', 'CONN_CLOSING', 'CONN_ESTABLISHED', 'CONN_FIN_WAIT1', 'CONN_FIN_WAIT2', 'CONN_LAST_ACK', 'CONN_LISTEN', 'CONN_NONE', 'CONN_SYN_RECV', 'CONN_SYN_SENT', 'CONN_TIME_WAIT', 'Error', 'IOPRIO_CLASS_BE', 'IOPRIO_CLASS_IDLE', 'IOPRIO_CLASS_NONE', 'IOPRIO_CLASS_RT', 'NUM_CPUS', 'NoSuchProcess', 'Popen', 'Process', 'RLIMIT_AS', 'RLIMIT_CORE', 'RLIMIT_CPU', 'RLIMIT_DATA', 'RLIMIT_FSIZE', 'RLIMIT_LOCKS', 'RLIMIT_MEMLOCK', 'RLIMIT_MSGQUEUE', 'RLIMIT_NICE', 'RLIMIT_NOFILE', 'RLIMIT_NPROC', 'RLIMIT_RSS', 'RLIMIT_RTPRIO', 'RLIMIT_RTTIME', 'RLIMIT_SIGPENDING', 'RLIMIT_STACK', 'RLIM_INFINITY', 'STATUS_DEAD', 'STATUS_DISK_SLEEP', 'STATUS_IDLE', 'STATUS_LOCKED', 'STATUS_RUNNING', 'STATUS_SLEEPING', 'STATUS_STOPPED', 'STATUS_TRACING_STOP', 'STATUS_WAKING', 'STATUS_ZOMBIE', 'TOTAL_PHYMEM', 'TimeoutExpired', '_PY3', 'all', 'builtins', 'doc', 'file', 'name', 'package', 'path', 'version', '_assert_pid_not_reused', '_common', '_compat', '_deprecated', '_error', '_last_cpu_times', '_last_cpu_times_2', '_last_per_cpu_times', '_last_per_cpu_times_2', '_nt_disk_iostat', '_nt_net_iostat', '_nt_sysmeminfo', '_pmap', '_pslinux', '_psplatform', '_psposix', '_ptime_cpu_perc_nt', '_wraps', 'avail_phymem', 'avail_virtmem', 'cached_phymem', 'callable', 'cpu_percent', 'cpu_times', 'cpu_times_percent', 'defaultdict', 'disk_io_counters', 'disk_partitions', 'disk_usage', 'errno', 'get_boot_time', 'get_pid_list', 'get_process_list', 'get_users', 'namedtuple', 'net_io_counters', 'network_io_counters', 'os', 'phymem_buffers', 'phymem_usage', 'pid_exists', 'process_iter', 'pwd', 'signal', 'subprocess', 'swap_memory', 'sys', 'test', 'time', 'total_virtmem', 'used_phymem', 'used_virtmem', 'version_info', 'virtmem_usage', 'virtual_memory', 'wait_procs', 'warnings']

AJNOURI commented 9 years ago

Back to GNS3 1.3.12dev1 (install from git repo) No such issue

enter image description here

julien-duponchelle commented 8 years ago

How psutil and GNS3 is installed?

Thanks for the report

AJNOURI commented 8 years ago

Actually, it seems that I installed it through both pip and apt:

$ sudo pip freeze | grep util

docutils==0.12
ipython-genutils==0.1.0
psutil==3.2.2

$

$ apt-cache search psutil

psutils - PostScript document handling utilities
python-psutil - module providing convenience functions for managing processes
python3-psutil - module providing convenience functions for managing processes (Python3)
glances - CLI curses based monitoring tool
gpsbabel - GPS file conversion plus transfer to/from GPS units
page-crunch - PDF and PS manipulation for printing needs

By the way 1.4.0b4 installed in a virtualenv works fine:

virtualenv virt_env/gns341 --no-site-packages
cd virt_env/gns341
sudo pip3 install gns3-gui==1.4.0b4
sudo pip3 install gns3-server==1.4.0b4
julien-duponchelle commented 8 years ago

We need psutil > 3.0.0

But versions from apt doesn't provide the correct version: http://packages.ubuntu.com/trusty/python/python3-psutil

On Mon, Nov 30, 2015 at 1:39 PM AJ NOURI notifications@github.com wrote:

Actually, it seems that I installed it through both pip and apt:

$ sudo pip freeze | grep util

docutils==0.12 ipython-genutils==0.1.0 psutil==3.2.2

$

$ apt-cache search psutil

psutils - PostScript document handling utilities python-psutil - module providing convenience functions for managing processes python3-psutil - module providing convenience functions for managing processes (Python3) glances - CLI curses based monitoring tool gpsbabel - GPS file conversion plus transfer to/from GPS units page-crunch - PDF and PS manipulation for printing needs

By the way 1.4.0b4 installed in a virtualenv works fine:

virtualenv virt_env/gns341 --no-site-packages cd virt_env/gns341 sudo pip3 install gns3-gui==1.4.0b4 sudo pip3 install gns3-server==1.4.0b4

— Reply to this email directly or view it on GitHub https://github.com/GNS3/gns3-server/issues/361#issuecomment-160618098.

grossmj commented 8 years ago

Should we check psutil version and have an explicit error message?

julien-duponchelle commented 8 years ago

I think we should probably check, sadly we can have the same issue with all the dependencies provided by apt.

julien-duponchelle commented 8 years ago

I just add a check. We should promote the deb package instead of pypi for ubuntu