python-import

Existing Django project deployment using Apache and Mod_wsgi (windows)

只谈情不闲聊 提交于 2020-01-15 07:21:30
问题 I have a django project which I took it from github. I would like to run the project on my local using apache server. I have installed apache and want to run the project. But I am always getting this error. raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'core.settings' (Is it on sys.path?): No module named cms.models Please find the configuration I am using. Python 2.7 Django 1.4 database in

Python 3.4 setuptools namespace setup does not work

馋奶兔 提交于 2020-01-15 05:00:09
问题 I am trying to create namespace packages for a modular project. The core system has the following packages homie homie.api homie.events homie.mods I want to install the respective modules as sub-packages of homie.mods . Therefor I provided the respective homie.__init__.py and homie.mods.__init__.py with the following content: from pkg_resources import declare_namespace declare_namespace(__name__) My testing module is structured as follows: homie homie/__init__.py homie/mods homie/mods/__init_

Python: why does importing a package sometimes grant access to modules underneath it but sometimes not?

一世执手 提交于 2020-01-14 14:54:18
问题 Python import mechanism is always a myth for me. Sometimes importing a package can grant access to the modules underneath it. For instance, import urllib urllib.parse.unquote gives <function urllib.parse.unquote> which shows functions are accessible even with only the package (i.e. urllib in this case) imported but not down to the module file. This is done within Jupyter notebook. But when I do the same thing in terminal >>> import urllib >>> urllib.parse.unquote Traceback (most recent call

Why can't I import statsmodels directly?

末鹿安然 提交于 2020-01-14 14:35:13
问题 I'm certainly missing something very obvious here, but why does this work: a = [0.2635,0.654654,0.365,0.4545,1.5465,3.545] import statsmodels.robust as rb print rb.scale.mad(a) 0.356309343367 but this doesn't: import statsmodels as sm print sm.robust.scale.mad(a) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-5-1ce0c872b0be> in <module>() ----> 1 print statsmodels.robust.scale.mad(a) AttributeError:

Pycharm: Marking a folder as 'sources root' is not recursive for subfolders

断了今生、忘了曾经 提交于 2020-01-14 11:33:33
问题 I've followed pycharm documentation to set up the IDE to resolve imports. However it seems that each folder containing *.py files needs to be explicitly added as 'sources root' in order for the IDE to resolve all references. Can this be done recursively from a root folder? Is this the correct way to get the IDE to resolve all codebase references, or have I not set up my project structure correctly? I have already followed other methods for resolving references in the IDE here and here but to

Pycharm: Marking a folder as 'sources root' is not recursive for subfolders

寵の児 提交于 2020-01-14 11:32:02
问题 I've followed pycharm documentation to set up the IDE to resolve imports. However it seems that each folder containing *.py files needs to be explicitly added as 'sources root' in order for the IDE to resolve all references. Can this be done recursively from a root folder? Is this the correct way to get the IDE to resolve all codebase references, or have I not set up my project structure correctly? I have already followed other methods for resolving references in the IDE here and here but to

Python 2.7 not working anymore: cannot import name md5

天大地大妈咪最大 提交于 2020-01-14 06:59:48
问题 I installed python 3.6.3 on my server yesterday (ubuntu 14.04), and now I cannot run python 2.7 (in the virtual envs and on the 'main env'). I've been looking around google for this, without success. I tried to re-intall openssl as I red. Can anyone help me ? I'm going mad. ---> Here is the message whenever i tried to execute a python script (or pip): *ERROR:root:code for hash md5 was not found. Traceback (most recent call last): File "/usr/local/lib/python2.7/hashlib.py", line 147, in

Why do I get a 'NameError' with this import?

隐身守侯 提交于 2020-01-14 05:30:18
问题 I'm building a web app that uses Flask and SQLAlchemy, but I can't seem to see the reason why this won't import correctly and work. I'm trying to test my database that I'm building, but I keep getting a NameError : File1: from flask.ext.sqlalchemy import SQLAlchemy from flask import Flask from File2 import db, data1, data2, data3 File2: from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///DB_File.db' #

Why do I get a 'NameError' with this import?

怎甘沉沦 提交于 2020-01-14 05:30:13
问题 I'm building a web app that uses Flask and SQLAlchemy, but I can't seem to see the reason why this won't import correctly and work. I'm trying to test my database that I'm building, but I keep getting a NameError : File1: from flask.ext.sqlalchemy import SQLAlchemy from flask import Flask from File2 import db, data1, data2, data3 File2: from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///DB_File.db' #

Why has the cyclical import issue disappeared?

青春壹個敷衍的年華 提交于 2020-01-13 20:24:25
问题 There is an obvious cyclical import error when importing this package: File __init__.py : from . import modules File forward.py : from .modules import ext_modules def forward(dest): if dest in ext_modules: print("forwarding to {}".format(ext_modules[dest])) File modules.py : from . import forward ext_modules = {} def main(): ext_modules['test'] = 'TEST' forward.forward('test') This import problem can be solved e.g. by exchanging lines 1 and 3 in the modules.py file. So far I think I