shebang

Why can't the import command be found?

本秂侑毒 提交于 2020-01-13 08:17:29
问题 I am using the input function from fileinput module to accept script via pipes or input file Here is the minimum script: finput.py import fileinput with fileinput.input() as f: for line in f: print(line) After making this script executable, I run ls | ./finput.py and get unexpected error message ./finput.py: line 1: import: command not found ./finput.py: line 3: syntax error near unexpected token `(' ./finput.py: line 3: `with fileinput.input() as f:' The only fix I found is when I add #!/usr

Why can't the import command be found?

不打扰是莪最后的温柔 提交于 2020-01-13 08:17:08
问题 I am using the input function from fileinput module to accept script via pipes or input file Here is the minimum script: finput.py import fileinput with fileinput.input() as f: for line in f: print(line) After making this script executable, I run ls | ./finput.py and get unexpected error message ./finput.py: line 1: import: command not found ./finput.py: line 3: syntax error near unexpected token `(' ./finput.py: line 3: `with fileinput.input() as f:' The only fix I found is when I add #!/usr

Why can't the import command be found?

本小妞迷上赌 提交于 2020-01-13 08:17:04
问题 I am using the input function from fileinput module to accept script via pipes or input file Here is the minimum script: finput.py import fileinput with fileinput.input() as f: for line in f: print(line) After making this script executable, I run ls | ./finput.py and get unexpected error message ./finput.py: line 1: import: command not found ./finput.py: line 3: syntax error near unexpected token `(' ./finput.py: line 3: `with fileinput.input() as f:' The only fix I found is when I add #!/usr

Python Script: Runs in Shell but fails in real life because cant import module

為{幸葍}努か 提交于 2020-01-06 21:04:02
问题 I have a script that runs fine in the Python Shell, but when double clicked it fails to import the PIL module(but it does import the PIL module in the Shell). What is wrong? Do I need a different shebang? I am on Windows 7: #!/usr/bin/env python """ """ try: from PIL import Image import os import datetime import time except Exception, e: raw_input(str(e)) # Running this script in the Shell, the code gets to here # Running this script in real life (just double click it) it prints "no module

Raspberry pi Python shebang with cgi server

痞子三分冷 提交于 2020-01-05 13:13:57
问题 I am trying to run a local CGI server on my raspberry pi to host a webpage with a single link, that link is to a CGI script which is supposed to trigger another script and then print HTML code to redirect back to the starting page (so that it doesn't hang) in the servers root directory i have: index.html favicon.ico Server.py cgi-bin my server is set up to use the cgi-bin folder for cgi-scripts. the issue i am having is i cannot seem to make the scripts callable, is so instead of typing

Why won't my Ruby script execute?

橙三吉。 提交于 2020-01-02 23:14:30
问题 So, I made a simply ruby script, #!/usr/bin/env ruby puts "Hello!" When I try to run it in terminal it doesn't put "Hello!" on the screen. I have tried entering chmod +x test.rb ( test.rb is the name of my file). When I run it, it doesn't give me an error, it just doesn't display "Hello!". Any help will be much appreciated. I have looked everywhere for a possible answer, and I have found nothing so far. 回答1: I'd guess that you're trying to run it as just test like this: $ test But test is a

Dealing with multiple python versions when python files have to use #!/bin/env python

本小妞迷上赌 提交于 2020-01-02 01:56:17
问题 I have this problem: System A runs Ubuntu and needs Python 2.6 for a bunch of different things. I Installed Python 2.7 separately on System A System B has Python 2.7 natively. I have a python script BLAH which says #!/bin/env python up top. Further down it executes another script SIGH , which up top also says: #!/bin/env python . BLAH needs to run on either System A or System B , and it always needs to run Python 2.7 ---- Part of my solution so far: Have a wrapper script that first tries to

Git pre-commit hook not working on windows

别说谁变了你拦得住时间么 提交于 2020-01-01 18:20:11
问题 I have a git pre-commit hook, but after commiting to the local repo, the script does not get called. This is how it looks, it is in python, the name of the hook file is called pre-commit without any extension: #!C:/Users/al/AppData/Local/Programs/Python/Python35-32 python import sys, os sys.exit(1) 回答1: Your pre-commit hook might suffer from one or more of the following issues: Is the shebang line correct? The shebang line should be the complete path to the executable which is used to run the

How to make an executable phar?

荒凉一梦 提交于 2019-12-31 10:49:08
问题 I want to start a phar script as an executable, directly by doing foo.phar <params> instead of php foo.phar <params> . 回答1: It's easy by modifying the default stub (adding the shebang corresponding to php). // start buffering. Mandatory to modify stub. $phar->startBuffering(); // Get the default stub. You can create your own if you have specific needs $defaultStub = $phar->createDefaultStub('index.php'); // Adding files $phar->buildFromDirectory(__DIR__, '/\.php$/'); // Create a custom stub

How to make the Shebang be able to choose the correct Python interpreter between python3 and python3.5

一笑奈何 提交于 2019-12-30 06:40:34
问题 I'm developing a set of script in python3, as shebang I use this: #!/usr/bin/env python3 Everything goes ok, but in some virtual machines where are executed the name of interpreter is python3.5 . I will like to be able to execute my scripts in both enviroment but I can't change the filesystem of virtual machine (so I discard solutions like make a link from python3.5 to python3 ) I look at man of env but I don't find any way to specify a searching pattern or something like that. I try to set