I am trying to get my django server running from within PyCharm. I am able to start the server with no errors, but as soon as I browse to a page in the app I get the following error in the console:
pydev debugger: starting
Validating models...
0 errors found
Django version 1.4.10, using settings 'oneanddone.settings.local'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Users/bsilverberg/gitRepos/oneanddone/vendor/lib/python/django/contrib/staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "/Users/bsilverberg/gitRepos/oneanddone/vendor/lib/python/django/core/handlers/wsgi.py", line 241, in __call__
response = self.get_response(request)
File "/Users/bsilverberg/gitRepos/oneanddone/vendor/lib/python/django/core/handlers/base.py", line 82, in get_response
urlconf = settings.ROOT_URLCONF
File "/Users/bsilverberg/gitRepos/oneanddone/vendor/lib/python/django/utils/functional.py", line 185, in inner
return func(self._wrapped, *args)
AttributeError: 'Settings' object has no attribute 'ROOT_URLCONF'
[09/Dec/2013 09:00:41] "GET /en-US/ HTTP/1.1" 500 59
I have a settings/local.py file and a settings/base.py file, and when I start the server from the terminal everything works fine. When starting from PyCharm I get the above error. My local settings file is getting loaded, as I can inspect the value of settings at this point in the code and can see my local values, but it seems like the settings from base.py are not being picked up (as that is where ROOT_URLCONF is defined).
So this doesn't seem to be an issue with DJANGO_SETTINGS_MODULE - it is finding the local.py file.
I'm running PyCharm 2.7.3 and django 1.4.
The most frustrating thing about this is that I had this working with a similar application a few months ago, and cannot figure out why it's not working now.
I just figured it out. All I had to do was point to the settings folder, instead of a specific file in the folder, and it all works.
Related
I'm trying to publish django using Microsoft IIS. I got an error when accessing http://localhost. Django version is 3.1.7 and python is 3.9.2, windows server 2019.
Error occurred while reading WSGI handler:
Traceback (most recent call last):
File "c:\program files\python39\lib\site-packages\wfastcgi.py", line 791, in main
env, handler = read_wsgi_handler(response.physical_path)
File "c:\program files\python39\lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler
handler = get_wsgi_handler(os.getenv("WSGI_HANDLER"))
File "c:\program files\python39\lib\site-packages\wfastcgi.py", line 603, in get_wsgi_handler
handler = getattr(handler, name)
AttributeError: module 'django.core' has no attribute 'wsgi'
StdOut:
StdErr:
There are many reasons for this error, you can try below methods to solve this error:
In your Django project, there is a init.py file, remove it and try again.
Try to find your Python folder (C:\python27 by default) and forcibly reset the permissions, i.e. Replace all child object permissions with inheritable permissions from this object as shown here: https://serverfault.com/questions/475612/replace-permission-entries-on-all-child-objects-using-icacls
If the problem cannot be solved, please share your project path and Web.config file.
at the moment i'm going to a Django course, to learn about web programming and as IDLE we're using PyCharm.
When I write the following commands to the terminal(cmd) i'm receiving an unicode error, I searched for other topics related to this one but I couldn't find the right answer. I mean I'm just not asking this to ask a question. In the end, i'll send you all commands and tracebacks,
My name contains Ö and Ü and its in my C: users folder name too, thats why I thought the problem was because of that, and that's why I just uninstalled python and reinstalled it to a new folder in D: but the problem haven't solved. I'm still receiving same error, after running server with the following code :
python manage.py runserver
while typing :
django-admin startproject myblog_
cd myblog_
python manage.py startapp gonderiler
these, I'm not receiving any error, "myblog_" is project name and "gonderiler" is app. name. But when I run server, I receive the following error:
also
python manage.py migrate
didn't fix the issue.
Thanks all ! I hope we'll find a solution together.!
I just copied all(not only traceback) from cmd to make it more clear,
Microsoft Windows [Sürüm 6.1.7601]
Telif Hakkı (c) 2009 Microsoft Corporation. Tüm hakları saklıdır.
(yeni_django) D:\yazilim24 django\dnm>django-admin startproject myblog_
(yeni_django) D:\yazilim24 django\dnm>cd myblog_
(yeni_django) D:\yazilim24 django\dnm\myblog_>python manage.py startapp gonderiler
(yeni_django) D:\yazilim24 django\dnm\myblog_>python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
August 09, 2018 - 11:19:49
Django version 2.1, using settings 'myblog_.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x035D2618>
Traceback (most recent call last):
File "D:\yazilim24 django\dnm\venv\yeni_django\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "D:\yazilim24 django\dnm\venv\yeni_django\lib\site-packages\django\core\management\commands\runserver.py", line 140, in inner_run
ipv6=self.use_ipv6, threading=threading, server_cls=self.server_cls)
File "D:\yazilim24 django\dnm\venv\yeni_django\lib\site-packages\django\core\servers\basehttp.py", line 164, in run
httpd = httpd_cls(server_address, WSGIRequestHandler, ipv6=ipv6)
File "D:\yazilim24 django\dnm\venv\yeni_django\lib\site-packages\django\core\servers\basehttp.py", line 67, in __init__
super().__init__(*args, **kwargs)
File "D:\py37\lib\socketserver.py", line 450, in __init__
self.server_bind()
File "D:\py37\lib\wsgiref\simple_server.py", line 52, in server_bind
HTTPServer.server_bind(self)
File "D:\py37\lib\http\server.py", line 140, in server_bind
self.server_name = socket.getfqdn(host)
File "D:\py37\lib\socket.py", line 677, in getfqdn
hostname, aliases, ipaddrs = gethostbyaddr(name)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd6 in position 11: invalid continuation byte
Hello guys I've solved my own issue with this ;
https://www.howtogeek.com/howto/windows-vista/change-your-computer-name-in-windows-vista/
Whoever will have the same issue, just go and change your computer's name with universal chars. The program's path doesn't matter that much.
The issue could be resolved by just saving those files where you made changes.
I too had these errors and just resolved by saving the files.
I'm having trouble starting Flask for Python 2.7 via Eclipse & Chrome; it's so temperamental am having trouble clarifying the situations it works/doesn't:
Files are .project (Eclipse), init.py & pymongo1.py
from flask import Flask
app = Flask(__name__)
#app.route('/')
def index():
return 'index page'
app.run(debug=True)
I load Eclipse, hit Run and get:
pydev debugger: starting (pid: 5296)
Finding files... done.
Importing test modules ... * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
pydev debugger: starting (pid: 2312)
Finding files... done.
Importing test modules ...
which simply hands. In Chrome, http://127.0.0.1:5000/ or 127.0.0.1:5000/ won't load anything. Changing 'index page' to 'Index page' & hitting save gives
* Detected change in 'C:\\Users\\Eddie\\Desktop\\dev\\health\\pymongo1.py', reloading
127.0.0.1 - - [28/Sep/2015 14:57:49] "GET / HTTP/1.1" 200 -
pydev debugger: Start reloading module: "pymongo1" ...
pydev debugger: Start reloading module: "pymongo1" ...
..and keeps Chrome loading. Hitting Run on Eclipse then gives:
pydev debugger: Start reloading module: "pymongo1" ...
pydev debugger: Start reloading module: "pymongo1" ...
* Detected change in 'C:\\Users\\Eddie\\Desktop\\dev\\health\\pymongo1.py', reloading
pydev debugger: Start reloading module: "pymongo1" ...
* Detected change in 'C:\\Users\\Eddie\\Desktop\\dev\\health\\pymongo1.py', reloading
Traceback (most recent call last):
File "C:\Users\Eddie\Downloads\eclipse\plugins\org.python.pydev_4.0.0.201504132356\pysrc\pydev_runfiles.py", line 468, in __get_module_from_str
mod = __import__(modname)
File "C:\Users\Eddie\Downloads\eclipse\plugins\org.python.pydev_4.0.0.201504132356\pysrc\pydev_monkey_qt.py", line 71, in patched_import
return original_import(name, *args, **kwargs)
File "C:\Users\Eddie\Desktop\dev\health\pymongo1.py", line 115, in <module>
app.run(debug=True)
File "C:\Python27\lib\site-packages\flask-0.10.1-py2.7.egg\flask\app.py", line 772, in run
run_simple(host, port, self, **options)
File "C:\Python27\lib\site-packages\werkzeug-0.10.4-py2.7.egg\werkzeug\serving.py", line 623, in run_simple
reloader_type)
File "C:\Python27\lib\site-packages\werkzeug-0.10.4-py2.7.egg\werkzeug\_reloader.py", line 229, in run_with_reloader
reloader.run()
File "C:\Python27\lib\site-packages\werkzeug-0.10.4-py2.7.egg\werkzeug\_reloader.py", line 131, in run
self.trigger_reload(filename)
File "C:\Python27\lib\site-packages\werkzeug-0.10.4-py2.7.egg\werkzeug\_reloader.py", line 111, in trigger_reload
sys.exit(3)
SystemExit: 3
ERROR: Module: pymongo1 could not be imported (file: C:\Users\Eddie\Desktop\dev\health\pymongo1.py).
Tried shutting down other apps in case they run on the same port, like Google Photos. Any clues why it temperamentally loads content/seems to be getting stuck on the 'importing test module' part? Regards
Resolved by #riotburn and #Joe Doherty. The py file needed starting from Windows PowerShell.
I am trying to set up a django application in Visual Studio 2012 that will publish to Google App Engine. I have a simple hello World Application set up in Visual Studio using pytools that I can run successfully in the development environment.
I added an app.yaml file, downloaded the AppEngine SDK and imported the existing application to the Google App Engine Launcher application. If I start the application locally using the App Engine Launcher, it starts but the page is just an error. I get the following from the log:
2013-05-23 07:47:03 Running command: "['C:\\Python27\\pythonw.exe', 'C:\\Program Files\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=8080', '--admin_port=8000', 'Z:\\gridtreecontrol\\GridTreeView\\GridTreeView']"
INFO 2013-05-23 07:47:09,496 devappserver2.py:522] Skipping SDK update check.
WARNING 2013-05-23 07:47:09,523 api_server.py:329] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2013-05-23 07:47:09,543 api_server.py:153] Starting API server at: http://localhost:61149
INFO 2013-05-23 07:47:09,552 dispatcher.py:164] Starting server "default" running at: http://localhost:8080
INFO 2013-05-23 07:47:09,558 admin_server.py:117] Starting admin server at: http://localhost:8000
ERROR 2013-05-23 12:47:32,108 wsgi.py:235]
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 223, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\core\handlers\wsgi.py", line 219, in __call__
self.load_middleware()
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\core\handlers\base.py", line 39, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\utils\functional.py", line 184, in inner
self._setup()
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\conf\__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "C:\Program Files\Google\google_appengine\lib\django-1.4\django\conf\__init__.py", line 95, in __init__
raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings
INFO 2013-05-23 07:47:32,128 server.py:585] default: "GET / HTTP/1.1" 500 -
It seems like it wants me to make some adjustments to sys.path, but I feel like if I did that, it won't propagate those changes to the production server on Google App Engine. I have tried publishing the application to the server, but get the same error there.
I do not get this error when running the application in Visual Studio.
You should not try to develop a standalone Django application and then try to convert it to GAE. There are many differences in running Django inside GAE, and it's best to start from there in the first place.
I don't know why it's important to you to be able to run your app "inside" VS. Again, you should use the GAE development server - you can continue to write your code in VS, and the devserver will even reload when it detects code changes. You might be able to configure VS to use the GAE devserver instead of the Django one, but it sounds like a lot of unnecessary fiddling.
im new to django and python , im trying to do runserver on a piece of django code and im running into the following problems,
Kinnovates-MacBook-Pro:platformsite Kinnovate$ python manage.py runserver
Running in development mode.
Running in development mode.
Running in development mode.
Running in development mode.
Validating models...
0 errors found
Django version 1.4b1, using settings 'platformsite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
self.load_middleware()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware pp.middleware: "No module named pp.middleware"
im running python2.7 1.4b Django on a macOSX10.7
how do i fix this?
You have a middleware class specified in settings.MIDDLEWARE_CLASSES that Django is trying to import, yet it isn't available on your Python path.
You should make sure that you have obtained the middleware sources and that your Python path is properly configured.