sys.path

PYTHONPATH variable blank

て烟熏妆下的殇ゞ 提交于 2019-12-11 07:36:38
问题 According to documentation, sys.path is initialized from PYTHONPATH when python session starts. However, in my case, PYTHONPATH variable is empty. When I execute this in terminal: echo $PYTHONPATH it returns blank. On the other hand, when I start python and inspect sys.path: import sys print (sys.path) I get back a long list of paths. Where do those get loaded from? What am I missing? 回答1: Check the documentation again: It says [ sys.path is initialized] from the environment variable

Google App Engine, Change which python version

廉价感情. 提交于 2019-12-11 03:53:29
问题 I'm trying to use the GCS client library with my app engine app and I ran into this - "In order to use the client library in your app, put the /src/cloudstorage directory in your sys.path so Python can find it." First, does this mean I need to move the directory into my sys.path OR does it need to add the ~/src/cloudstorage/ to my PATH environment variable? Second, when I print sys.version and sys.path from the App Engine Interactive Console, I see a Python Version of 2.7.2, but when I print

Setting a default sys.path for a Notebook

早过忘川 提交于 2019-12-10 03:34:20
问题 I have all my .py files inside a folder script and all my IPython-notebooks under a folder named Notebook. There are multiple cross dependencies for each notebook file on one or more files on script. Having sys.path.append on top of every notebook seems cumbersome and I am hoping there is a way to add a default lookup path just like we add PYTHONPATH to .bash_profile . Now I do the following: import sys sys.path.append("<path where DeriveFinalResultSet.py exists>) import DeriveFinalResultSet

Setting a default sys.path for a Notebook

ぃ、小莉子 提交于 2019-12-05 03:05:41
I have all my .py files inside a folder script and all my IPython-notebooks under a folder named Notebook. There are multiple cross dependencies for each notebook file on one or more files on script. Having sys.path.append on top of every notebook seems cumbersome and I am hoping there is a way to add a default lookup path just like we add PYTHONPATH to .bash_profile . Now I do the following: import sys sys.path.append("<path where DeriveFinalResultSet.py exists>) import DeriveFinalResultSet as drs I wish to have a setting where I can do the below: import DeriveFinalResultSet as drs Nick T To

How is the python module search path determined on Mac OS X?

こ雲淡風輕ζ 提交于 2019-12-04 21:50:12
问题 When a non built-in module is imported, the interpreter searches in the locations given by sys.path . sys.path is initialized from these locations (http://docs.python.org/library/sys.html#sys.path): the directory containing the input script (or the current directory) PYTHONPATH the installation-dependent default While the first two sources are straight-forward, can anyone explain how the third one works, and what possibilities there are for influencing it? Although I would be interested in a

How do you modify sys.path in Google App Engine (Python)?

落花浮王杯 提交于 2019-12-03 19:56:19
问题 I've tried adding the following line to my handler script (main.py), but it doesn't seem to work: sys.path.append('subdir') subdir lives in the my root directory (i.e. the one containing app.yaml ). This doesn't seem to work, because when I try to import modules that live in subdir , my app explodes. 回答1: 1) Ensure you have a blank __init__.py file in subdir . 2) Use a full path; something like this: import os import sys sys.path.append(os.path.join(os.path.dirname(__file__), 'subdir')) Edit:

setting import module path in Jython - strange behavior

人盡茶涼 提交于 2019-12-03 16:21:24
I'm building Java to Jython bridge class. The task I'm trying to solve is to make Jython to look for python modules in my application working directory (also known as program execution directory). I'm doing so by appending System.getProperty("user.dir") value to the sys.path: pySysState = new PySystemState(); //add working directory into sys.path pySysState.path.append(new PyString(System.getProperty("user.dir"))); log_.info("Jython sys state initialized. sys.path: " + this.pySysState.path); I get ImportError exception: python module 'user_module' was not found. sys.path: ['<other jars>\\Lib',

Get parent of current directory from Python script

做~自己de王妃 提交于 2019-12-03 03:05:33
问题 I want to get the parent of current directory from Python script. For example I launch the script from /home/kristina/desire-directory/scripts the desire path in this case is /home/kristina/desire-directory I know sys.path[0] from sys . But I don't want to parse sys.path[0] resulting string. Is there any another way to get parent of current directory in Python? 回答1: Using os.path To get the parent directory of the directory containing the script (regardless of the current working directory),

Managing sys.path for multiple developers

泄露秘密 提交于 2019-12-02 13:32:02
问题 The problem I'm facing is small but annoying: A colleague is working on one project in version control system X (VCS-X). Another colleague is working in another version control system Y and uses the packages from X. Unfortunately colleague in VCS-X uses local import and modifies his path using sys.path.append('trunk/my_location') in their code. My view is that this is wrong practice as colleagues in X forces colleague Y to edit the code prior to being able to run it, merely because their repo

Managing sys.path for multiple developers

99封情书 提交于 2019-12-02 04:01:41
The problem I'm facing is small but annoying: A colleague is working on one project in version control system X (VCS-X). Another colleague is working in another version control system Y and uses the packages from X. Unfortunately colleague in VCS-X uses local import and modifies his path using sys.path.append('trunk/my_location') in their code. My view is that this is wrong practice as colleagues in X forces colleague Y to edit the code prior to being able to run it, merely because their repo is named differently. How should these dependencies be managed? Example: Developer X : >>> sys.path