Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: expected str, bytes or os.PathLike object, not NoneType #13

Open
Yutao-Jin opened this issue Dec 1, 2021 · 4 comments
Open

Comments

@Yutao-Jin
Copy link

Yutao-Jin commented Dec 1, 2021

image

macserver@MacServer ~ % /Users/macserver/Desktop/transmission-trackers.py

Traceback (most recent call last):
File "/Users/macserver/Desktop/transmission-trackers.py", line 54, in
cache_file = path.join(env.get('TEMP',env.get('TMP',None)) ,'.cache/trackers.txt')
File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/posixpath.py", line 76, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

I'm using python 3.9.9 on macOS

@S-Riot
Copy link

S-Riot commented Jan 21, 2022

This error comes up on Unix based systems. Basically, the script is searching for a temporary directory on the system environment settings and, when it doesn't find it, you get that error.
On Mac, specifically, go to the terminal and type:
env TMP
or
env TEMP
if those variables are not present you will receive the following message or similiar:
env: TMP: No such file or directory
In this case, you have to add a permanent enviromental variable. In order to do this, open a terminal window and type
nano .bash_profile
at the end of the file, add:
export TMP=/tmp
save and close the file, it's advisable to restart the computer.
This should solve the problem above.
In my case, just to let you know, I was working with UBUNTU 20.10 and after that, I had to tweak the permissons on the directory that is created by the python script inside the temporary directory.

@trotskylenin
Copy link
Contributor

trotskylenin commented Mar 29, 2022

Same issue here.
I replaced None by '' and it worked.
The issue is not that TMP is not an environment variable in Unix systems, because that should be handled properly if the path is not found.
The issue is that None is not a valid value type for the second parameter of env.get

@trotskylenin
Copy link
Contributor

trotskylenin commented Mar 29, 2022

Go to Case 6 in this url and you will see proper usage:
https://www.geeksforgeeks.org/python-os-environ-object/?ref=gcse

@trotskylenin
Copy link
Contributor

I've just proposed a pull request to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants