XMC and Python - Install additional modules

  • 0
  • 1
  • Question
  • Updated 2 months ago
  • In Progress
Hello,

what is the best way to install additional python modules on XMC?
As I see easy_install is present on the XMC but no PIP.

Do new installed modules survive an XMC update?

Best regards
Stephan
Photo of SH

SH

  • 4,174 Points 4k badge 2x thumb

Posted 3 months ago

  • 0
  • 1
Photo of tknv

tknv, Employee

  • 382 Points 250 badge 2x thumb
Hi Stephan,
I think you can try:

# @METADATASTART
#@DetailDescriptionStart
################################################################
# System Script
#
# Script        : Using pip.
# Revision      : 1.0
# Last updated  : 7/17/2018
# Purpose       : To know using pip at XMC.
#
################################################################
#@DetailDescriptionEnd
# @ScriptDescription "Using pip"
# @SectionStart ( description = "pip install some")
# @SectionEnd
# @MetaDataEnd
import sys
sys.path.append('/usr/local/Extreme_Networks/NetSight/appdata/scripting')
import os
import pip
import inspect
from xmclib import emc_vars
from xmclib import logger

print("Running Python version is: %s" % sys.version)
print("Running Python PATH is: %s" % sys.executable)
print("Running module os is: %s" % inspect.getfile(os))
print("---Start pip install a")
pip.main(['install', 'a'])
print("Running module a is: %s" % inspect.getfile(a))

There would be two way, install package from XMC and from shell of running XMC.I believe from XMC is safer. But no guarantee, possible name space conflict etc.
Also from shell would break system ( running XMC environment) Python environment.
(Edited)
Photo of SH

SH

  • 4,174 Points 4k badge 2x thumb
Hello tknv,

unfortunately the installation fails with the following exception on XMC 8.1.3.65. Do you have an idea what's wrong?

---Start pip install a
Collecting a
  Downloading https://files.pythonhosted.org/packages/22/94/2c8ae1f5a1173347404c7d94a7dd822ff059ff6d19f8fa6240ffde1cb956/a-1.0.tar.gz
    Error [Errno 2] No such file or directory while executing command python setup.py egg_info
Exception:
Traceback (most recent call last):
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/commands/install.py", line 335, in run
    wb.build(autobuilding=True)
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/commands/install.py", line 335, in run
    wb.build(autobuilding=True)
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/req/req_set.py", line 376, in prepare_files
    discovered_reqs.extend(self._prepare_file(
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/req/req_set.py", line 376, in prepare_files
    discovered_reqs.extend(self._prepare_file(
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/req/req_set.py", line 634, in _prepare_file
    abstract_dist.prep_for_dist()
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/req/req_set.py", line 129, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/req/req_install.py", line 435, in run_egg_info
    call_subprocess(
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/site-packages/pip/utils/__init__.py", line 665, in call_subprocess
    proc = subprocess.Popen(
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/subprocess.py", line 859, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/local/Extreme_Networks/NetSight/jython/Lib/subprocess.py", line 1369, in _execute_child
    raise OSError(errno.ENOENT, os.strerror(errno.ENOENT))
OSError: [Errno 2] No such file or directory
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Traceback (most recent call last):
  File "<string>", line 30, in <module>
NameError: name 'a' is not defined 
Best regards
Stephan