Python command line arg before the file - python-2.7

What is the -3 in:
python -3 my_file.py
I saw this line somewhere and can't find what arguments before the file mean.

Related

Python wrapper install gives "Command "python setup.py egg_info" failed with error code 1"

I've been trying to install this Python wrapper for the past two days. I went through all the other questions here on Stack Overflow. Tried literally everything, and nothing seems to work.
Processing /../../../../../wrappers/Python
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-twPZdY-build/setup.py", line 50, in <module>
**cffi_args
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/local/lib/python2.7/site-packages/setuptools/dist.py", line 319, in __init__
_Distribution.__init__(self, attrs)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__
self.finalize_options()
File "/usr/local/lib/python2.7/site-packages/setuptools/dist.py", line 386, in finalize_options
ep.load()(self, ep.name, value)
File "/private/tmp/pip-twPZdY-build/.eggs/cffi-1.10.0-py2.7-macosx-10.11-x86_64.egg/cffi/setuptools_ext.py", line 188, in cffi_modules
add_cffi_module(dist, cffi_module)
File "/private/tmp/pip-twPZdY-build/.eggs/cffi-1.10.0-py2.7-macosx-10.11-x86_64.egg/cffi/setuptools_ext.py", line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File "/private/tmp/pip-twPZdY-build/.eggs/cffi-1.10.0-py2.7-macosx-10.11-x86_64.egg/cffi/setuptools_ext.py", line 25, in execfile
exec(code, glob, glob)
File "../ffi_build.py", line 34, in <module>
ffi.set_source('../_ffi', None)
File "/private/tmp/pip-twPZdY-build/.eggs/cffi-1.10.0-py2.7-macosx-10.11-x86_64.egg/cffi/api.py", line 612, in set_source
raise ValueError("'module_name' must not contain '/': use a dotted "
ValueError: 'module_name' must not contain '/': use a dotted name to make a 'package.module' location
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-twPZdY-build/
I've reinstalled everything at least twice, updated, tried sudo -H, but nothing seems to work. It seems like a problem with setuptools, but I have no idea how to fix it.
Mac OSX 10.11.6 (El Capitan)
Python 2.7.13
Pip 9.0.1
After carefully reading through the error message, I managed to find the file called ffi_build.py under the Python folder I was trying to bind. As stated in the error message, at line 34 there was a module naming statement that contained a '/'. By replacing that '/' with a '.' I solved the issue and managed to bind the Python wrapper with no issue whatsoever.

Python pdfkit can't find wkhtmltopdf executable

a few months ago I had created a little script to convert URLs to PDF files, this morning I tried to convert another link but I got this error from py prompt:
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\pdfkit\api.py", line 24, in from_url
configuration=configuration, cover_first=cover_first)
File "C:\Python27\lib\site-packages\pdfkit\pdfkit.py", line 42, in __init__
self.configuration = (Configuration() if configuration is None
File "C:\Python27\lib\site-packages\pdfkit\configuration.py", line 27, in __init__
'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf)
IOError: No wkhtmltopdf executable found: ""
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf -
https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
I've googled a lot but still can't find solution. Anyone can help me?
I found the solution, I don't know why but python was replacing my environment path "C:\Program Files\wkhtmltopdf\bin" with "C:\Program Files\wkhtmltopdin" because of "\b" so I just replaced "\b" with "/b" and solved.

"ValueError: name is too long" in kivy

I am having this error while compiling my app in kivy using buildozer and I just can't figure out what It means. I tried shortening the name o0f my app but that didn't worked.
File "build.py", line 507, in <module>
make_package(args)
File "build.py", line 326, in make_package
make_tar('assets/private.mp3', ['private', args.private], args.ignore_path)
File "build.py", line 203, in make_tar
tf.add(fn, afn)
File "/usr/lib/python2.7/tarfile.py", line 2014, in add
self.addfile(tarinfo, f)
File "/usr/lib/python2.7/tarfile.py", line 2037, in addfile
buf = tarinfo.tobuf(self.format, self.encoding, self.errors)
File "/usr/lib/python2.7/tarfile.py", line 999, in tobuf
return self.create_ustar_header(info)
File "/usr/lib/python2.7/tarfile.py", line 1016, in create_ustar_header
info["prefix"], info["name"] = self._posix_split_name(info["name"])
File "/usr/lib/python2.7/tarfile.py", line 1103, in _posix_split_name
raise ValueError("name is too long")
ValueError: name is too long
# Command failed: /usr/bin/python build.py --name MobilGame --version 1.0 --package org.test.myapp --private /home/nabeel/Desktop/game/ProjectGame/.buildozer/android/app --sdk 14 --minsdk 8 --orientation landscape debug
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2
I Just figured it out, There were other files in the directory which were also being added to the compiled binary. Once I moved the files to a new directory They compiled like butter.

Error in Tkinter; TclError: missing newline on line...)

I am really working with a bigger program in Tkinter but this code raises the same error:
import Tkinter as tk
root=tk.Tk()
root.title('ROOT')
root.configure(background='blue')
root.option_readfile('tkinter_style_sheet.txt')
Button(root, text='Press Me!' ).grid(row=1, column=1)
mainloop()
The "tkinter_style_sheet.txt" in question, is a .txt file written in Notepad whith text as follows:
*font: Times 8 bold
*Button*font: Times 10 bold
*Button*borderwidth:3
*Button*relief: raised
*Button*width: 3
*Button*height: 1
*Button*pady:3
With the given text file and code, I receive the following output:
Traceback (most recent call last):
File "C:/Python27/problem_with_tkinter.py", line 7, in <module>
root.option_readfile('tkinter_style_sheet.txt')
File "C:\Python27\lib\lib-tk\Tkinter.py", line 658, in option_readfile
self.tk.call('option', 'readfile', fileName, priority)
TclError: missing newline on line 7
I don't understand the error, I tried adding a '\n' character at line 7 but, not surprisingly, it didn't solve the problem. Anyone having an idea what's wrong?
do this on line 7:
*font:Times 8 bold
*Button*font:Times 10 bold
*Button*borderwidth:3
*Button*relief: raised
*Button*width: 3
*Button*height: 1
*Button*pady:3
enter a newline after the end of the last line.

issue with subprocess.call

Python 2.7.3 with ubuntu:
Trying to run a program, (youtube-dl in this example) with subprocess.call with some arguments, I encounter the following issue. consider the following script:
try.py:
#!/usr/bin/python
from subprocess import call
url = "https://www.youtube.com/watch?v=8SbUC-UaAxE"
myArray = ['./youtube-dl {}'.format(url),'-x','--audio-format mp3']
#print the array before executing:
for item in myArray:
print item,
#execute:
call(myArray)
This script prints outputs:
oris#oris:~/Desktop/YouTube/backend$ ./try.py
./youtube-dl https://www.youtube.com/watch?v=8SbUC-UaAxE -x --audio-format mp3
Traceback (most recent call last):
File "./try.py", line 16, in <module>
call(myArray)
File "/usr/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Strangly, On the first line of the output I see the script does output ./youtube-dl https://www.youtube.com/watch?v=8SbUC-UaAxE -x --audio-format mp3 This command runs perfectly from bash directly, but produces an OSError from python. I also thought maybe to try and supply the url as an argument like this:
myArray = ['./youtube-dl', url,'-x','--audio-format mp3']
but than youtube-dl has an error of incorrect usage:
oris#oris:~/Desktop/YouTube/backend$ ./try.py
Usage: youtube-dl [options] url [url...]
youtube-dl: error: no such option: --audio-format mp3
./youtube-dl https://www.youtube.com/watch?v=8SbUC-UaAxE -x --audio-format mp3
I've read youtube-dl source to see how it handles the supplied arguments with optparse. I don't see the url as an argument there, so I'm guessing i'm passing the arguments to subprocess.call incorrectly.
Side note: another thing I find odd is the fact the print here takes effect after the subprocess call, as opposed to their order on my script. Is something happening here asynchronously?
What am I missing here? Many thanks
--audio-format and mp3 should be passed as separated arguments:
myArray = ['./youtube-dl', url, '-x', '--audio-format', 'mp3']