0

The task is to open an application called t32 from the command line in a linuix machine using python script and 2 arguments is what I understand. but i am facing the following error:

sh-5.0$ python2 t32start.py --t32path /home/uif24704/t32 --target makena
Python not detected in PATH. Attempting to add python executable path to PATH
Added Python directory /usr/bin to PATH
Selected target: makena
Selected session: None
Traceback (most recent call last):
File "t32start.py", line 847, in <module>
generate_buildinfo()
File "t32start.py", line 318, in generate_buildinfo
tmpfile = os.getenv('TEMP') + os.sep + cmmfilename
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

note: i have already set the TEMP path

2
  • It's telling you what the error is. The script you're trying to run is trying to add None to a str. What do you see when you run echo $TEMP in your shell? Commented Oct 13, 2022 at 9:38
  • You may have set TEMP, but did you export it? If you just assign it it's a regular shell variable but not an environment variable; only environment variables are copied to subprocesses. (BTW, the standard name for a variable describing where to put temporary files is TMPDIR, not TEMP) Commented Jan 21, 2023 at 15:55

2 Answers 2

0

It appears that variable cmmfilename is unset therefore causes and error when you are joining it with the string values. You should provide the code on how you call this Python script and how this script parses these arguments. For example: python main.py --filename="/sample_dir" and parser.add_argument("--filename", help="Working directory.").

You may also want to lookup on how to provide and read command line arguments (for example, see this question) as there are multiple ways in doing so.

Sign up to request clarification or add additional context in comments.

Comments

0

Replace the following in t32start.py line 318

tmpfile = os.getenv('TEMP') + os.sep + cmmfilename

with

import tempfile
tmpfile = tempfile.gettempdir() + os.sep + cmmfilename

This uses a more generic cross-platform approach to getting the temporary directory. In the current code, os.getenv('TEMP') returns None which cannot be concatenated with the trailing string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.