I thought I'd post this here because hours of googling ended up fruitless. I have an obj file and I'm trying to use the python script included with three.js to export it for use in three.js however I have never used python before and don't know what I'm doing.
These have been my steps so far:
I've opened up the Python GUI, opened up convert_obj_three.py, clicked run -> run module, and then I get this:
======= RESTART: C:\three.js\utils\converters\obj\convert_obj_three.py =======
Usage: convert_obj_three.py -i filename.obj -o filename.js [-m morphfiles*.obj] [-c morphcolors*.obj] [-a center|top|bottom] [-s flat|smooth] [-t binary|ascii] [-d invert|normal]
When I try typing in something like convert_obj_three.py -i test.obj -o test.js I get an SyntaxError: invalid syntax error.
test.obj is in the same folder as convert_obj_three.py however that does not seem to be the issue as no matter what I type I seem to get a syntax error...
Run the command:
convert_obj_three.py -i test.obj -o test.js
at a command prompt. On Windows, Python will have to be in your path for this to work, that's an option in the installer (at least in 2.7) right at the bottom of the list of options, IME sometimes not visible - very easy to miss - so scroll down to find it.
Related
While using the generate_tfrecord.py, I'm always getting this error of "generate_tfrecord.py: error: unrecognized arguments".
But, I haven't changed anything, and I've used the same command from the custom object detection tutorial, from the TFOD website.
Link: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html
Tried both on Google Collab and also on local python environment, still same issue.
Anyone has experienced this error before, if so, how did you solve it? Please help. Thanks!
python generate_tfrecord.py -x [PATH_TO_IMAGES_FOLDER]/train -l [PATH_TO_ANNOTATIONS_FOLDER]/label_map.pbtxt -o [PATH_TO_ANNOTATIONS_FOLDER]/train.record
Changes I made:
python generate_tfrecord.py -x C:/Users/prana/Desktop/cnn_system/images/train -l C:/Users/prana/Desktop/cnn_system/annotations/label_map.pbtxt -o C:/Users/prana/Desktop/cnn_system/annotations/train.record
On Collab, I tried this:
!python generate_tfrecord.py -i /content/trainingdemo/images/train -l /content/trainingdemo/annotations/label_map.pbtxt -o /content/trainingdemo/annotations/train.record
All the files have been double checked, they all exist in the right path.
this worked for me, it may work for someone else.
Try not to leave any spaces in the line of code, replace spaces with _
BEFORE:
python generate_tfrecord.py -x D:/Semestre/graduation project/files/TensorFlow/workspace/training/images/train -l D:/Semestre/graduation project/files/TensorFlow/workspace/training/annotations/labelmap.pbtxt -o D:/Semestre/graduation project/files/TensorFlow/workspace/training/annotations/train.record
AFTER:
python generate_tfrecord.py -x D:/Semestre/graduation_project/files/TensorFlow/workspace/training/images/train -l D:/Semestre/graduation_project/files/TensorFlow/workspace/training/annotations/labelmap.pbtxt -o D:/Semestre/graduation_project/files/TensorFlow/workspace/training/annotations/train.record
I had a space between graduation project
I also had the same issue. After a whole day of search I figured out the solution!
We need to put those file names in inverted comma ("myFile") which have blank space in their names(my File).
Example:
Convert this:
python generate_tfrecord.py -x D:/Semestre/graduation project/files/TensorFlow/workspace/training/images/train -l D:/Semestre/graduation project/files/TensorFlow/workspace/training/annotations/labelmap.pbtxt -o D:/Semestre/graduation project/files/TensorFlow/workspace/training/annotations/train.record
To this:
python generate_tfrecord.py -x D:/Semestre/"graduation project"/files/TensorFlow/workspace/training/images/train -l D:/Semestre/"graduation project"/files/TensorFlow/workspace/training/annotations/labelmap.pbtxt -o D:/Semestre/"graduation project"/files/TensorFlow/workspace/training/annotations/train.record
In Short : put those filenames in inverted commas who are having space in between.
My Files to "My Files"
Hope this would help:)
I am trying to run my python script without writing python func.py.
I've added to my script file #!/usr/bin/python2.7
did chmod +x func.py
when I try to run: ./func.py -p show -c all
the script works fine but if I try to take off the "flags" (-p , -c) or the "./" or ".py" it won't work.
taking flags off returns:
[root#pg66 tmp]# ./func.py show all
usage: func.py [-h] [-p PROCESS] [-c CLUSTER] [-t TYPE]
func.py: error: unrecognized arguments: show all
taking "./" & ".py" off returns:
[root#pg66 tmp]# func.py -p show -c all
-bash: func.py: command not found
edit: i have 3 flags -p -c -t , dont know where the -h came from. -t can be null so when i write -p show -c all it works.
you can simply use the chmod +* x in the location with the python file. This makes it easier for linux/unix After that you can run it by ./main.py Assuming the file is named as main.py. You can also remove the .py extension then give the permission by chmod +* x and after that then just execute by ./main. Another way to do this is simply going to the execution script of your terminal then add an alias for directly running the script just by typing the alias name
I am playing around with this Instagram ID tracker because my friends are constantly changing usernames so I can never keep up. The code is from here. The only way I am aware of, is that you have to go to any sort of terminal and type a command in this format
$ usage: t.py [-h] -u USERNAME [-p] [-s] [-t]
I've already tried to do some on my own and I recently saw other people running command lines in the Python text editor but it doesn't seem to work for me. This is what I did
import os
import main
import api
os.system('python3 main.py -u <USERNAME>')
There are 2 files, main.py and api.py. I imported both but when I run it, it still says
usage: t.py [-h] -u USERNAME [-p] [-s] [-t]
t.py: error: the following arguments are required: -u/--username
Is there an easier way to go about this?
I am trying to run python code that I pull directly from Github raw URL using the Python interpreter. The goal is never having to keep the code stored on file system and run it directly from github.
SO far I am able to get the raw code from github using the curl command but since it is a multi-line code, I get the error that python cannot find the file.
python 'curl https://github.url/raw/path-to-code'
python: can't open file 'curl https://github.url/raw/path-to-code': [Errno
2] No such file or directory
How do I pass a multi-line code block to the Python interpreter without having to write another .py file (which would defeat the purpose of this exercise)?
You need to pipe the code you get from cURL to the Python interpreter, something like:
curl https://github.url/raw/path-to-code | python -
UPDATE: cURL prints download stats to STDERR, if you want it silenced you can use the -s modifier when calling it:
curl -s https://github.url/raw/path-to-code | python -
There is no way to do this via Python interpreter, without first retrieving the script then passing it to the interpreter.
The currant Python command line arguments can be accessed with --help argument:
usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Options and arguments (and corresponding environment variables):
-b : issue warnings about str(bytes_instance), str(bytearray_instance)
and comparing bytes/bytearray with str. (-bb: issue errors)
-B : don't write .pyc files on import; also PYTHONDONTWRITEBYTECODE=x
-c cmd : program passed in as string (terminates option list)
-d : debug output from parser; also PYTHONDEBUG=x
-E : ignore PYTHON* environment variables (such as PYTHONPATH)
-h : print this help message and exit (also --help)
-i : inspect interactively after running script; forces a prompt even
if stdin does not appear to be a terminal; also PYTHONINSPECT=x
-I : isolate Python from the user's environment (implies -E and -s)
-m mod : run library module as a script (terminates option list)
-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x
-OO : remove doc-strings in addition to the -O optimizations
-q : don't print version and copyright messages on interactive startup
-s : don't add user site directory to sys.path; also PYTHONNOUSERSITE
-S : don't imply 'import site' on initialization
-u : force the binary I/O layers of stdout and stderr to be unbuffered;
stdin is always buffered; text I/O layer will be line-buffered;
also PYTHONUNBUFFERED=x
-v : verbose (trace import statements); also PYTHONVERBOSE=x
can be supplied multiple times to increase verbosity
-V : print the Python version number and exit (also --version)
when given twice, print more information about the build
-W arg : warning control; arg is action:message:category:module:lineno
also PYTHONWARNINGS=arg
-x : skip first line of source, allowing use of non-Unix forms of #!cmd
-X opt : set implementation-specific option
file : program read from script file
- : program read from stdin (default; interactive mode if a tty)
arg ...: arguments passed to program in sys.argv[1:]
If you want it all on one line then use | to set multiple commands
curl https://github.url/raw/path-to-code --output some.file|python some.file
Trying to install easy_install (IRONIC) and it is not wanting to cooperate with me.
I am running the following command in terminal with python2.7
curl https://bootstrap.pypa.io/ez_setup.py -o - | python
returns me -->
-bash: https://bootstrap.pypa.io/ez_setup.py: No such file or directory
is it a simple fix?
This should work:
curl https://bootstrap.pypa.io/ez_setup.py -s | python
Unless redirected otherwise, cURL will output the received body to STDOUT, so you do not have to pass it -o - (which really should not do anything according to the docs). You should pass it -s in order to suppress the progress meter and any errors. Then pipe it directly into python. Given no other arguments, python will determine STDIN as the source of the script to execute.