pythonpath

Apache with virtualenv and mod_wsgi : ImportError : No module named 'django'

南楼画角 提交于 2019-12-18 12:29:24
问题 I'm trying to serve a little django project with the following Apache configuration : Apache virtualhost configuration : <VirtualHost *> ServerName servername [...] <Directory "/path/to/project/project"> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess project python-path=/path/to/project:/path/to/Envs/venv/lib/python3.5/site-packages WSGIScriptAlias / /path/to/project/project/wsgi.py </VirtualHost> I also have the following wsgi.py : import os from django.core.wsgi

PYTHONPATH not working for sudo on GNU/Linux (works for root)

好久不见. 提交于 2019-12-17 16:32:35
问题 EDIT: Works for root, sudo is the problem. Read below. I have a directory with my own libraries, e.g. my Python libraries are located at /home/name/lib/py . I've added this directory to Python's PATH for all users (including root) by adding the following line to /etc/bash.bashrc : export PYTHONPATH=$PYTHONPATH:/home/name/lib/py It works for all users (including root). But it doesn't work for sudo. Is there any way I can make sudo use /etc/bash.bashrc ? EDIT: More information: I've added

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

How to configure custom PYTHONPATH with VM and PyCharm?

↘锁芯ラ 提交于 2019-12-17 04:15:18
问题 I am using IntelliJ with the Python plugin and the Remote Interpreter feature to communicate with my Vagrant VM. It sets up the remote interpreter correctly to use my VM's interpreter. But, I use a custom PYTHONPATH in my VM, and I would like IntelliJ to recognize that path and include the modules in that path when developing. How do I configure IntelliJ/PyCharm's remote interpreter to use a custom PYTHONPATH on the VM? 回答1: For PyCharm 5 (or 2016.1), you can: select Preferences > Project

PyLint “Unable to import” error - how to set PYTHONPATH?

十年热恋 提交于 2019-12-17 03:51:25
问题 I'm running PyLint from inside Wing IDE on Windows. I have a sub-directory (package) in my project and inside the package I import a module from the top level, ie. __init__.py myapp.py one.py subdir\ __init__.py two.py Inside two.py I have import one and this works fine at runtime, because the top-level directory (from which myapp.py is run) is in the Python path. However, when I run PyLint on two.py it gives me an error: F0401: Unable to import 'one' How do I fix this? 回答1: There are two

A test running with nosetests fails with ImportError, but works with python command

浪尽此生 提交于 2019-12-14 02:35:12
问题 When run a test with python mycore/tests4extractor.py it works. If run the test with nosetests ./mycore/tests4extractor.py it fails with ImportError: No module named extractor . I am in the helpers folder. The project structure is: helpers/ mycore/ __init__.py extractor.py tests4extractor.py Setting PYTHONPATH to the absolute path to helpers and/or helpers/mycore doesn't help. Answer tests4extractor.py: import mycore from extractor import extract should be changed to: import mycore from

What's .pydistutils.cfg for?

匆匆过客 提交于 2019-12-13 12:25:47
问题 I work on two servers, and on one server .pydistutils.cfg looks like: install_scripts=~/opt_old/bin install_data=~/opt_old/share install_lib=~/usr/lib/python2.6/site-packages I think, this creates problems with using pip and linking libraries on local versions of python. On the second server, the file is non existent, and I don't have any issues. Why do we need this file and why is PYTHONPATH not sufficient? I installed a local version of Python and renamed the file .pydistutils.cfg. Hence,

How and why does PyCharm alter Python's import logic?

坚强是说给别人听的谎言 提交于 2019-12-13 11:55:00
问题 I have a PyCharm 1.2.1 on Windows. I have to edit different branches of the same project - somewhat heavy branches, because they live in different folders on disk - say it to be c:\apps\alpha and c:\apps\beta . For each such folder PYTHONPATH variable should be adjusted to point to appropriate vendor libraries which live somewhere inside project root folder ( c:\alpha\vendor ,...). I managed to work around this issue by starting PyCharm from cmd batch file which sets necessary PYTHONPATH

Changing Python path under Mac OS for applications other than the terminal

笑着哭i 提交于 2019-12-13 00:07:53
问题 I have a Python script that I'd like to be able to run with a minimum of fuss from the Finder or Quicksilver. Unfortunately, any way of running the script that doesn't use the terminal can't find my libraries. For example, running do shell script "~/anaconda/bin/python -c 'import sys; print len(sys.path)'" from Applescript gives a value of 13, but running ~/anaconda/bin/python -c 'import sys; print len(sys.path)' from the terminal gives 15. This makes me think that .bash_profile may not be