Questions tagged [python]

Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability.

For more information please see the official website. Note that programming questions might be more fit for Stack Overflow unless they are specifically UNIX-related.

2306 questions
92
votes
6 answers

Execute shell commands in Python

I'm currently studying penetration testing and Python programming. I just want to know how I would go about executing a Linux command in Python. The commands I want to execute are: echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A PREROUTING…
Xanmashi
  • 1,053
37
votes
3 answers

Is it possible to pass arguments into a Python script?

I know how to pass arguments into a shell script. These arguments are declared in AWS datapipeline and passed through. This is what a shell script would look like: firstarg=$1 secondarg=$2 How do I do this in Python? Is it the exact same?
10
votes
1 answer

What does PIP stand for?

What does pip stand for? Does it stands for Python Package Installer? No, I don't think so, it is PPI
7
votes
1 answer

Python not recognizing LD_LIBRARY_PATH?

I am trying to install Python2.7 on cr-48 chromebook in developer mode, and face a weird issue that I am having hard time searching for a solution on google. First some background.. the root partition is mounted readonly, so I have been installing…
haridsv
  • 179
6
votes
1 answer

$PYTHONPATH is not working at all

I added $PYTHONPATH permanently via .bashrc like this export PYTHONPATH=$PYTHONPATH:/path/to/python-sdk and now when I start python, it doesn't show up in sys.path` and the libraries can't be imported. I know I could add it in python like this, but…
6
votes
3 answers

import error fabric.api

I am trying to import fabric.api and having issues. I installed fabric using pip and it works fin when I run import fabric in the interpreter. But when I do from fabric.api import * it spews out an error saying "No module named api". I am using…
6
votes
1 answer

RuntimeError: You need gevent installed to use this worker

I need gevent to run docker-registry but i have this error: Error: class uri 'gevent' invalid or not found: [Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 139, in load_class mod =…
stecog
  • 2,271
6
votes
1 answer

How to stop python from looking for .py files

I have a system with very little resources (embedded). Because of that I only installed the python .pyo files (=byte compiled & optimized) for my program. Now when such a program runs, python keeps looking for .py files (probably to see if the .pyo…
5
votes
3 answers

python + how to print value that comes from os.system

why this simple python script not print the real redhat version? version = os.system( ' cat /etc/redhat-release | awk \'{print $7}\' ' ) print ("my version is " ,version) when I run it we got: 7.2 ('my version is ', 0) why we get 0 instead…
jango
  • 423
4
votes
0 answers

mypy: Type annotations when subclass methods have different kwargs

I've several times run into a problem with adding type annotations to existing code, where an abstract base class has a method and then subclasses implement the method and add some optional keyword arguments. Let's say the code looks something like…
4
votes
2 answers

Getting error while running jupyter-notebook

i am getting a traceback error while running jupyter-notebook. i am providing the screenshot of the traceback call : Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/notebook/services/sessions/sessionmanager.py",…
Cad
  • 41
4
votes
3 answers

How can I get a python script to "remember" user input?

I have a script that asks the user for the path to their desired directory default_path = '/path/to/desired/directory/' user_path = raw_input("Enter new directory [{0}]: ".format(default_path)) or default_path print user_path The script has a…
4
votes
2 answers

'NoneType' object has no attribute 'decompressobj' while installing Bootstrap setuptools

I am trying to install python 3.2, and to get setuptools and pip in python 3.2. Everything seems to work right in python 2.7. However when I try to install setuptools using this code wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python3.2 I…
Ravi
  • 143
3
votes
1 answer

Issues with Skyperious

I am trying to install Skyperious on Ubuntu 13.10, I have installed all the required dependencies, my python version is Python 2.7.5+. When I run the following code from terminal python main.py Nothing happens. Not even any errors. I am in the…
3
votes
2 answers

pipe function arguments to command line arguments in python

I have a python code (cmd.py) which accepts files as command line arguments and process using parse_args. I want to pass files from another code (files.py) to cmd.py, just like passing function arguments. Can this be done without modifying cmd.py?
Akhitha
  • 43
  • 1
  • 2
  • 6
1
2 3 4 5 6