I'm trying to run a python app from amazon EC2 large instance. However, Its complaining in scipy because it can't find a thing called _winreg.
I don't know how to reconfigure this so its no longer an issue.
$ python2 app.py
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with stat
Traceback (most recent call last):
File "app.py", line 111, in <module> app = create_app().run(debug=True)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 772, in run run_simple(host, port, self, **options)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 622, in run_simple reloader_type)
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 265, in run_with_reloader reloader.run()
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 155, in run for filename in chain(_iter_module_files(), self.extra_files):
File "/usr/local/lib/python2.7/dist-packages/werkzeug/_reloader.py", line 70, in _iter_module_files for package_path in getattr(module, '__path__', ()):
File "/usr/lib/python2.7/dist-packages/scipy/lib/six.py", line 116, in __getattr__ _module = self._resolve()
File "/usr/lib/python2.7/dist-packages/scipy/lib/six.py", line 105, in _resolve return _import_module(self.mod)
File "/usr/lib/python2.7/dist-packages/scipy/lib/six.py", line 76, in _import_module __import__(name) ImportError: No module named _winreg """
Check out the comments on the answer of this post.
I'm guessing by using the watchdog module it doesn't import "stat" which seems to look for this _winreg package.
In other words, installing the module "watchdog" seems to do the trick.
Related
I'm deploying a django app made with django channels using nginx, gunicorn and daphne. During deployment when I run python manage.py makemigrations, I get the following error. Could it be because the python version on my local machine was 3.7 and on remote ubuntu server is 3.5?
from cryptography import x509
/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.
from cryptography import x509
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/apps.py", line 20, in ready
monkeypatch_django()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/hacks.py", line 10, in monkeypatch_django
from .management.commands.runserver import Command as RunserverCommand
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/management/commands/runserver.py", line 11, in <module>
from channels.routing import get_default_application
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/routing.py", line 10, in <module>
from channels.http import AsgiHandler
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/http.py", line 152, in <module>
class AsgiHandler(base.BaseHandler):
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/http.py", line 214, in AsgiHandler
#sync_to_async
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/asgiref/sync.py", line 375, in sync_to_async
return SyncToAsync(func, thread_sensitive=thread_sensitive)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/asgiref/sync.py", line 262, in __init__
self._is_coroutine = asyncio.coroutines._is_coroutine
AttributeError: module 'asyncio.coroutines' has no attribute '_is_coroutine'
The error is beacause of asgiref package that uses asyncio.coroutines._is_coroutine attribute since version 3.2.2.
You can install asgiref 3.2.1 and this problem doesn't happen.
pip install asgiref==3.2.1
I'm working on a Rally reporting tool for my team in Python, and I'm trying to package it using cx-freeze. I'm getting a ModuleNotFound error, and I'm wondering if it's because pygal isn't supported by cx-freeze (really hoping this isn't the case because I'd have to rewrite a lot of things)
celinaperalta$ /Users/celinaperalta/Documents/NYLTesting/rally-exports/build/exe.macosx-10.9-x86_64-3.7/RallyGUI ; exit;
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cx_Freeze/initscripts/__startup__.py", line 40, in run
module.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/cx_Freeze/initscripts/Console.py", line 37, in run
exec(code, {'__name__': '__main__'})
File "RallyGUI.py", line 8, in <module>
File "/Users/celinaperalta/Documents/NYLTesting/rally-exports/build/exe.macosx-10.9-x86_64-3.7/RallyReportTool.py", line 7, in <module>
import pygal
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pygal/__init__.py", line 28, in <module>
import pkg_resources
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 959, in <module>
class Environment:
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 963, in Environment
self, search_path=None, platform=get_supported_platform(),
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 190, in get_supported_platform
plat = get_build_platform()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 395, in get_build_platform
plat = get_platform()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sysconfig.py", line 675, in get_platform
get_config_vars(),
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sysconfig.py", line 551, in get_config_vars
_init_posix(_CONFIG_VARS)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sysconfig.py", line 422, in _init_posix
_temp = __import__(name, globals(), locals(), ['build_time_vars'], 0)
ModuleNotFoundError: No module named '_sysconfigdata_m_darwin_darwin'
cx_freeze does not include all the packages automatically. When you find ModuleNotFoundError, you need to inlcude the module explicitly in your setup like -
build_exe_options = {'packages': ['_sysconfigdata_m_darwin_darwin']}
Following the Flask 0.11 documentation, I cloned the Flask repo, created a virtualenv, and installed Flask via pip install flask. I went into the examples/flaskr directory, set the FLASK_APP environment variable, then executed:
flask run
However, I got the following error:
Traceback (most recent call last):
File "c:\python34\Lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "c:\python34\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\GitHub\flask\venv\Scripts\flask.exe\__main__.py", line 9, in <module>
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 478, in main
cli.main(args=args, prog_name=name)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 345, in main
return AppGroup.main(self, *args, **kwargs)
File "d:\github\flask\venv\lib\site-packages\click\core.py", line 696, in main
rv = self.invoke(ctx)
File "d:\github\flask\venv\lib\site-packages\click\core.py", line 1055, in invoke
cmd_name, cmd, args = self.resolve_command(ctx, args)
File "d:\github\flask\venv\lib\site-packages\click\core.py", line 1094, in resolve_command
cmd = self.get_command(ctx, cmd_name)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 316, in get_command
rv = info.load_app().cli.get_command(ctx, name)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 209, in load_app
rv = locate_app(self.app_import_path)
File "d:\github\flask\venv\lib\site-packages\flask\cli.py", line 89, in locate_app
__import__(module)
ImportError: No module named 'flaskr'
How do I correctly run the flaskr example?
I was setting FLASK_APP=flaskr. Since I hadn't installed my app as a package in my virtualenv, I needed to add the .py extension.
export FLASK_APP=flaskr.py
Flask issue for the eclipse and PyDev extension, you can set a path like this.
Flask 1.0.2 and Python 3.6 already installed on Windows 10.
flask.cli.NoAppException
flask.cli.NoAppException: module 'src' has no attribute 'Hello'
Run Flask in proper folder path to resolve this issue.
I'm trying to push a django app to the production server, but for some reason it fails and says:
ImportError: The _imaging C module is not installed
The weird part is that when I use the development server on the same machine, it works just fine. PIL is installed, and I can import the _imaging module by hand in the shell. The production server uses Apache. Any ideas?
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "C:/portal2\compliance\views.py", line 91, in show_statement
doc.build(Story, onFirstPage=firstPage, onLaterPages=otherPage)
File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 1117, in build
BaseDocTemplate.build(self,flowables, canvasmaker=canvasmaker)
File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 877, in build
self.clean_hanging()
File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 510, in clean_hanging
self.handle_flowable(self._hanging)
File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 757, in handle_flowable
f.apply(self)
File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 140, in apply
getattr(doc,arn)(*args)
File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 1093, in handle_pageBegin
self._handle_pageBegin()
File "C:\Python27\lib\site-packages\reportlab\platypus\doctemplate.py", line 535, in handle_pageBegin
self.pageTemplate.onPage(self.canv,self)
File "C:/portal2\compliance\views.py", line 55, in firstPage
canvas.drawImage(img,0,0,8.5*inch,11*inch)
File "C:\Python27\lib\site-packages\reportlab\pdfgen\canvas.py", line 857, in drawImage
imgObj = pdfdoc.PDFImageXObject(name, image, mask=mask)
File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2094, in init
self.loadImageFromA85(src)
File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 2100, in loadImageFromA85
imagedata = map(string.strip,pdfutils.makeA85Image(source,IMG=IMG))
File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfutils.py", line 34, in makeA85Image
raw = img.getRGBData()
File "C:\Python27\lib\site-packages\reportlab\lib\utils.py", line 658, in getRGBData
annotateException('\nidentity=%s'%self.identity())
File "C:\Python27\lib\site-packages\reportlab\lib\utils.py", line 655, in getRGBData
self._data = im.tostring()
File "C:\Python27\lib\site-packages\PIL\Image.py", line 532, in tostring
self.load()
File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 164, in load
self.load_prepare()
File "C:\Python27\lib\site-packages\PIL\ImageFile.py", line 231, in load_prepare
self.im = Image.core.new(self.mode, self.size)
File "C:\Python27\lib\site-packages\PIL\Image.py", line 37, in getattr
raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed
identity=[ImageReader#0x4517a30 filename='C:\portal2\pdf\Certification_fullframe.tif']
handle_pageBegin args=()
PIL should be installed before library which uses it. I got similar problem with libimaging - PIL wasn't installed before libimaging so libimaging was compiled without it. Solution was uninstall libimaging and install it again with PIL already present in system.
Found the answer!
Trouble using PIL in Django app on Windows
I had to install a version of PIL that was precompiled to work with mod-wsgi.
I am trying to use the google appengine python SKD from my ubuntu lucid. I have already compiled python2.5. But when I execute any "dev_appserver.py" command with it I get the following error:
Traceback (most recent call last):
File "dev_appserver.py", line 69, in <module>
run_file(__file__, globals())
File "dev_appserver.py", line 65, in run_file
execfile(script_path, globals_)
File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver_main.py", line 90, in <module>
from google.appengine.tools import appcfg
File "/media/Ultimate/WebD/django/app_engine/google_appengine/google/appengine/tools/appcfg.py", line 59, in <module>
from google.appengine.tools import appengine_rpc
File "/media/Ultimate/WebD/django/app_engine/google_appengine/google/appengine/tools/appengine_rpc.py", line 24, in <module>
import fancy_urllib
File "/media/Ultimate/WebD/django/app_engine/google_appengine/lib/fancy_urllib/fancy_urllib/__init__.py", line 328, in <module>
class FancyHTTPSHandler(urllib2.HTTPSHandler):
AttributeError: 'module' object has no attribute 'HTTPSHandler'
I have checked the urllib2 moduls of python2.6 and python2.5 but there was no difference in the models defination and HTTPSHandelr is there in python2.5 too. So I guess it is some other sort of error.
I tried to run with the default python2.6 too but then I get the following error:
WARNING 2010-09-11 12:08:40,848 datastore_file_stub.py:657] Could not read datastore data from /tmp/dev_appserver.datastore
Traceback (most recent call last):
File "./dev_appserver.py", line 69, in <module>
run_file(__file__, globals())
File "./dev_appserver.py", line 65, in run_file
execfile(script_path, globals_)
File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver_main.py", line 449, in <module>
sys.exit(main(sys.argv))
File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver_main.py", line 426, in main
static_caching=static_caching)
File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver.py", line 3820, in CreateServer
server = HTTPServerWithScheduler((serve_address, port), handler_class)
File "/home/rohan/workspace/app_en/google_appengine/google/appengine/tools/dev_appserver.py", line 3840, in __init__
request_handler_class)
File "/usr/lib/python2.6/SocketServer.py", line 400, in __init__
self.server_bind()
File "/usr/lib/python2.6/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/lib/python2.6/SocketServer.py", line 411, in server_bind
self.socket.bind(self.server_address)
File "<string>", line 1, in bind
socket.error: [Errno 98] Address already in use
It works well in windows and even under wine.
Update
Problem with python2.6 solved.
I had configured my apache server for a django deployment on the 8080 and 80 port some time earlier.
But there is still same error with python2.5 isntallation.
Solved the issue...just needed to build all dependencies of python using:
apt-get build-dep python
python compiles with no error even when all the dependencies are not installed. It just skips the modules which require them and builds python.
Solution for missing HTTPSHandler:
Before you build python 2.5 from source you need to enable ssl-socket by editing Modules/Setup.dist (more info here http://paltman.com/2007/nov/15/getting-ssl-support-in-python-251/)
The method described in this post worked perfectly for me (Ubuntu 11.10).
http://dewbot.posterous.com/installation-of-python-25-and-google-app-engi