pythonpath

Customize module search path (PYTHONPATH) via pipenv

☆樱花仙子☆ 提交于 2019-11-27 17:24:47
问题 I have a Python project consisting of a Jupyter notebook, several scripts in a bin directory and modules in a src directory, with dependencies in a Pipfile : myproject ├── myproject.ipynb ├── Pipfile ├── Pipfile.lock ├── bin │ ├── bar.py │ └── foo.py └── src ├── baz.py └── qux.py The scripts foo.py and bar.py use the standard shebang #!/usr/bin/env python and can be run with pipenv shell : mymachine:myproject myname$ pipenv shell (myproject-U308romt) bash-3.2$ bin/foo.py foo However, I can't

How to add something to PYTHONPATH?

倖福魔咒の 提交于 2019-11-27 15:49:51
问题 I downloaded a package (called pysolr 2.0.15) to my computer to be used with Haystack. The instructions asks me to add pysolr to my PYTHONPATH. What exactly does that mean? After extracting the pysolr files, I ran the command python setup.py install and that's about it. What did that do and do I need to do anything else? Thanks for the help! 回答1: The pythonpath tells python were to look for modules, for example you might have written a library that you want to use in several applications and

What to set `SPARK_HOME` to?

北战南征 提交于 2019-11-27 12:55:58
问题 Installed apache-maven-3.3.3, scala 2.11.6, then ran: $ git clone git://github.com/apache/spark.git -b branch-1.4 $ cd spark $ build/mvn -DskipTests clean package Finally: $ git clone https://github.com/apache/incubator-zeppelin $ cd incubator-zeppelin/ $ mvn install -DskipTests Then ran the server: $ bin/zeppelin-daemon.sh start Running a simple notebook beginning with %pyspark , I got an error about py4j not being found. Just did pip install py4j (ref). Now I'm getting this error: pyspark

Import Error: No module named django

最后都变了- 提交于 2019-11-27 08:38:33
I am using centos linux. I had python 2.6 with django and now i upgraded to python 2.7. Python 2.6 is located in /usr/lib/python2.6. Python 2.7 is located in /usr/local/lib/python2.7. They both have site-packages directory and they both contain django 1.2. If i run python i get the 2.7 version. My problem is that if try to import django i get ImportError: No module named django I am not sure where is my PYTHONPATH defined and if this is what i need to change. anyone ? i ended up making a symbolic link to the 2.6 site-packages directory. jcollado To check your path, you can use the following

Effect of using sys.path.insert(0, path) and sys.path(append) when loading modules

回眸只為那壹抹淺笑 提交于 2019-11-27 05:14:48
问题 I was recently having a problem with a python ImportError, where the module was found when running on my local computer but not found on the CI server. I solved this problem by swapping sys.path.append(path) in my script with sys.path.insert(0, path) where path is the string module location. Since this is my module and not an installed package (related question), why does the order of paths fix this problem? 回答1: Because python checks in the directories in sequential order starting at the

Pyspark append executor environment variable

六眼飞鱼酱① 提交于 2019-11-27 03:35:32
问题 Is it possible to append a value to the PYTHONPATH of a worker in spark? I know it is possible to go to each worker node, configure spark-env.sh file and do it, but I want a more flexible approach I am trying to use setExecutorEnv method, but with no success conf = SparkConf().setMaster("spark://192.168.10.11:7077")\ .setAppName(''myname')\ .set("spark.cassandra.connection.host", "192.168.10.11") / .setExecutorEnv('PYTHONPATH', '$PYTHONPATH:/custom_dir_that_I_want_to_append/') It creates a

sys.path different in Jupyter and Python - how to import own modules in Jupyter?

自作多情 提交于 2019-11-27 00:50:48
问题 In Jupyter my own little module is not loaded but in python/bpython is everything is fine. When typing import sys print(sys.path) the path to my module will not in show in Jupyter but in python/bpython it is still there. I am using: PYTHONPATH in .bashrc to include my module, Jupyter and bpython inside a virtualenv. The most similar questions is this Cannot import modules in jupyter notebook; wrong sys.path How to configure Jupyter to load my modules automagically? 回答1: Here is what I do on

set pythonpath before import statements

蹲街弑〆低调 提交于 2019-11-27 00:33:13
问题 My code is: import scriptlib.abc import scriptlib.xyz def foo(): ... some operations but the scriptlib is in some other directory, so I will have to include that directory in environment variable "PYTHONPATH". Is there anyway in which I can first add the scriptlib directory in environment variable "PYTHONPATH" before import statement getting executed like : import sys sys.path.append('/mypath/scriptlib') import scriptlib.abc import scriptlib.xyz def foo(): ... some operations If so, is the

django import error - No module named core.management

孤者浪人 提交于 2019-11-26 21:40:12
Ok, I see plenty of these errors around. I have tried everything I know to do and have yet to figure this out. I am working on a development server running python 2.5 and Django 1.3. Django 1.3 was installed using python setup.py install after unpacking the tar.gz download. All works well, I seldom have the need to run manage.py but am trying to use the new staticfiles app and am running into problems. python manage.py collectstatic Traceback (most recent call last): File "manage.py", line 2, in <module> from django.core.management import execute_manager ImportError: No module named core

adding directory to sys.path /PYTHONPATH

五迷三道 提交于 2019-11-26 19:40:49
I am trying to import a module from a particular directory. The problem is that if I use sys.path.append(mod_directory) to append the path and then open the python interpreter, the directory mod_directory gets added to the end of the list sys.path. If I export the PYTHONPATH variable before opening the python interpreter, the directory gets added to the start of the list. In the latter case I can import the module but in the former, I cannot. Can somebody explain why this is happening and give me a solution to add the mod_directory to the start, inside a python script ? Ned Deily This is