Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python insert path

import sys
from os.path import abspath, dirname

sys.path.insert(0, dirname(dirname(abspath(__file__))))

path1 = dirname(abspath(__file__))  # current folder
path2 = dirname(path1)  # parent folder

print(path1)
print(path2)
Comment

add python to path

To add Python to the Windows Path, follow these steps:

1. Start the Run box and enter sysdm.cpl
2. In the System Properties window go to the Advanced tab and 
   click the Environment Variables button
3. In the System variable window, find the Path variable and 
   click Edit
4. Position your cursor at the end of the Variable value line 
   and add the path to the python.exe file, preceeded with 
   the semicolon character (;)
Comment

how to add path to python in windows

Simply add this path to your PYTHONPATH environment variable. 
To do this, go to Control Panel / System / Advanced / Environment variable, 
and in the "User variables" sections, check if you already have PYTHONPATH. 
If yes, select it and click "Edit", if not, click "New" to add it.

Paths in PYTHONPATH should be separated with ";".
Comment

add python to path windows 10

Either manually change it by doing the steps for the answer by skilliboi.

Or you can reinstall python and when you do that, make sure to tick the box that says:
Add python to PATH (or something like that)
Comment

python path addition

from pathlib import Path

data_folder = Path("source_data/text_files/")

file_to_open = data_folder / "raw_data.txt"

f = open(file_to_open)

print(f.read())
Comment

PREVIOUS NEXT
Code Example
Python :: parse int python 
Python :: creating django project 
Python :: installation of uvicorn for fastapi 
Python :: pandas convert string to datetime 
Python :: how to see if a number is prime in python 
Python :: Python Frozenset operations 
Python :: formula of factorial 
Python :: how to make python into exe 
Python :: ram clear in python 
Python :: find length of string in python 
Python :: ForeignKey on delete django 
Python :: bar plot group by pandas 
Python :: df insert 
Python :: get median using python 
Python :: how to separate url from text in python 
Python :: set python 3 as default mac 
Python :: create table pyspark sql 
Python :: how to make timer in python 
Python :: no python application found, check your startup logs for errors 
Python :: how to add space in st.write streamlit 
Python :: python number of elements in list of lists 
Python :: how to create multidimensional array in python using numpy 
Python :: how to encode emoji to text in python 
Python :: How to get the date from week number in Python? 
Python :: scrape email in a list from website python 
Python :: cufflink install python jupyter 
Python :: python how to align text writen to a file 
Python :: python countdown from 20 down to 0 
Python :: how to input data to the list in pythion 
Python :: text cleaning python 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =