Dec-06-2018, 03:47 PM
(This post was last modified: Dec-06-2018, 03:47 PM by saisankalpj.)
(Dec-06-2018, 01:10 PM)snippsat Wrote: I think you are mixing stuff together,what you do in first post is make a package.
(Dec-06-2018, 11:54 AM)saisankalpj Wrote: Is there any way to change the working directory in Pycharm itself,instead of code level,as I need the code to work through both cmd and pycharmTo make a folder that Python find wherever you in PyCharm or command line,
add that folder tosys.path
(this is where Python search for.py
files).
I find it easiest to not mess withPYTHONPATH
for adding own folders permanently.
The site module offers a method that takes care of adding tosys.path
without duplicates and.pth
files.
Make asitecustomize.py
file inC:\Python37\Lib\site-packages
or yoursite-packages
folder.
# sitecustomize.py import site site.addsitedir(r'E:\div_code')Test that it work.
C:\ λ ptpython >>> import sys >>> from pprint import pprint >>> pprint(sys.path) ['C:\\python37\\Scripts\\ptpython.exe', 'c:\\python37\\python37.zip', 'c:\\python37\\DLLs', 'c:\\python37\\lib', 'c:\\python37', 'c:\\python37\\lib\\site-packages', 'E:\\div_code'] <----For OS and Path look at Python 3.6/3.7 and pip installation under Windows
Now if a package(your first code) is placed eg inE:\div_code
,then python will find it.
so if i create sitecustomize.py file and keep it in
C:\Python37\Lib\site-packages
,will even pycharm recognize this as current working directory or it is only for command prompt?