sys.path

How to delete a certain path in sys.path in anaconda env (base)?

不想你离开。 提交于 2020-08-10 18:50:07
问题 I have installed a package with python setup.py install --user It looks it had been done in anaconda (base), though I can't remember. The module was installed in $HOME/.local/lib/python3.6/site-packages and the path is included in sys.path in anaconda (base). But even though I make another env, the path is still included in sys.path in new env. How can I completely remove the path? In the installed directory ($HOME/.local/.../site-packages), there are only two files of module directory and ..

prevent python from loading a pth file

与世无争的帅哥 提交于 2020-01-14 19:55:10
问题 My situation is as follows: I have a locally installed version of python. There exists also a global one, badly installed, which I do not want to use. (I don't have admin priviliges). On /usr/local/lib/site-packages there is a x.pth file containing a path to a faulty installation of numpy My PYTHONPATH does not have any of those paths. However, some admin generated script adds /usr/local and /usr/local/bin to my PATH (this is an assumption, not a known fact). This somehow results in the

Python can't find modules with PYTHONPATH set

大兔子大兔子 提交于 2020-01-04 23:48:27
问题 I’m totally confused with new python 2.7.10. I've installed python 2.7.10 from tar.xz, which was downloaded from official site. Then I've linked /usr/local/bin/python2.7 with /usr/bin/python2.7 and /usr/bin/python, but when I try to import module, I get ImportError: No module named "module_name" . For example: python -c "import gtk" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named gtk But if: cd /usr/lib/python2.7/dist-packages/gtk-2.0/

Jython - Configuring modules path into a jython script

旧巷老猫 提交于 2019-12-24 14:26:49
问题 Looks like function os.chdir() does not works for Jython, is there another way to switch of working directory in a Jython script ? (Get the following error while running my script: OSError: [Errno 0] chdir not supported in Java) Thanks in advance for any solution. EDIT: Question title updated to match the solution. Tags too. 回答1: What Grimmy asked make me think different about my original problem (thanks to you) My goal is (was) to define a path to find local jython modules. And so the

setting import module path in Jython - strange behavior

半世苍凉 提交于 2019-12-21 05:20:05
问题 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);

Python: select one of multiple installed module versions

跟風遠走 提交于 2019-12-17 15:39:39
问题 On my system, I have several modules installed multiple times. To give an example, numpy 1.6.1 is installed in the standard path at /usr/lib/python2.7/dist-packages , and I have an updated version of numpy 1.8.0 installed at /local/python/lib/python2.7/site-packages/ . The reason I cannot simply remove the old version is that I do not have permissions to change anything on my work computer. I however need to use the new numpy version. I have added /local/python/lib/python2.7/site-packages/ to

Python: select one of multiple installed module versions

☆樱花仙子☆ 提交于 2019-12-17 15:39:16
问题 On my system, I have several modules installed multiple times. To give an example, numpy 1.6.1 is installed in the standard path at /usr/lib/python2.7/dist-packages , and I have an updated version of numpy 1.8.0 installed at /local/python/lib/python2.7/site-packages/ . The reason I cannot simply remove the old version is that I do not have permissions to change anything on my work computer. I however need to use the new numpy version. I have added /local/python/lib/python2.7/site-packages/ to

Where does sys.path get replaced?

我们两清 提交于 2019-12-14 03:14:13
问题 Some library does change my sys.path in a way that I don't want it to. But I can't find it. The affected virtualenv has a lot of libraries installed. I replaced sys.path with a own class which alters the modifications, but this does not help, since the code seems to alter sys.path like this: sys.path= [...] + sys.path How can I find the "evil" code line and its stack trace? Related Debugging modifications of sys.path 回答1: I found the evil code line like this. I alter sys.globals['sys'] in

python cant find module in sys.path

自古美人都是妖i 提交于 2019-12-11 14:52:56
问题 I use the following command to install modules in home/.local since I dont have admin rights pip install --install-option="--prefix=$HOME/.local" package_name it is installed in my home dir and other cant run my script, so I move them to python lib/site-packages directory where others have access to. Then I add sys.path.insert(0, path_to_lib) in my script to import that module. This is how I install and use modules in my script and it always works fine. But when I did the same for a module

Sys.path.insert inserts path to module but imports are not working

半腔热情 提交于 2019-12-11 08:24:05
问题 I want to import a module in a project and it gives me lots of troubles because of an import error. So I decided to write a little test to see where the problem lies. I add a folder to my sys path and try to import it. And I get an Import Error: no module found named xyz Like this: import sys import os sys.path.insert(0, os.path.abspath('../../myfolder')) import myfolder print(sys.path) The sys.path is ['/Users/myuser/myproject/mywebsitefolder/myfolder/', ...] myfolder contains an __init__.py