Reputation: 113
I have seen this post asked before in stackoverflow but it was 4 years ago (How to fix the python path) so I am not sure wether this is the right solution because I am using a newer version of python (3.5.2). This is what I see in a Python Shell:
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import os
>>> os.environ['PYTHONPATH'].split(os.pathsep)
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
os.environ['PYTHONPATH'].split(os.pathsep)
File "C:\Users\John\AppData\Local\Programs\Python\Python35\lib\os.py", line 725, in __getitem__
raise KeyError(key) from None
KeyError: 'PYTHONPATH'
I want to find the pythonpath.So, how can I fix this error?
Upvotes: 0
Views: 9332
Reputation: 2720
First of all make sure if you have any environment variable with this name. I also got an error like this. I used PATH
instead of PYHONPATH
and this worked for me. I am working on Ubuntu btw.
Upvotes: 0
Reputation: 4441
There is no PYTHONPATH variable in your OS Environemental variables. Hence the error.
It is not created by Python installation (atleast in windows). You have to create one variable.
To check if there is one such environmental variable, type below command:
SET PYTHONPATH
You can also create and set it using below command
SETX PYTHONPATH <your desired path>
Upvotes: 1