-1

I have a pythonscript that imports argparse but since i dont have install priviledges I want to know if I can do someting like import argparse from path /path/to/argparse

Is this possible? IM new to python

WHEN I RUN THE SCRIPT IT SAYS ARGPARSE IS MISSING USING: Python 2.6.6 I CANT INSTALL PIP BECAUSE I DONT HAVE SUDO RIGHTS

hpaulj
  • 221,503
  • 14
  • 230
  • 353
Born vs. Me
  • 43
  • 2
  • 6

1 Answers1

1

The argparse module was added to python in version 2.7, see the official documentation:

https://docs.python.org/2/library/argparse.html

To use it in python 2.6 you can download/install a compatible version using pip, run the following command in the console/terminal (bash, cmd, etc. not python interpreter):

pip install argparse

To install pip, have a look at https://pip.pypa.io/en/stable/installing/. Check the python 2.6 specific instructions.

If you don't have root access this thread should help:

What is the purpose "pip install --user ..."?

Alternative solution:

  1. Download the argparse-module from https://raw.githubusercontent.com/ThomasWaldmann/argparse/master/argparse.py (linked from pypi)
  2. Place it in the same folder as the script requiring argparse
SimonF
  • 1,855
  • 10
  • 23