I'd like to put a flickr feed on my homepage using django-syncr; I followed the instructions on the homepage (http://code.google.com/p/django-syncr/), and the installation process was pretty smooth. Steps 1-3 work just fine, but Step 4 is where I run into problems.
When I try to run the commands shown:
from syncr.app.flickr import FlickrSyncr
I get the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/django_syncr-0.50-py2.7.egg/sync/app/flickr.py", line 11, in <module>
from syncr.flickr.models import *
File "/usr/local/lib/python2.7/dist-packages/django_syncr-0.50-py2.7.egg/syncr/flickr/models.py", line 1, in <module>
from django.db import models
File "/usr/lib/python2.7/dist-packages/django/db/__init__.py", line 14, in <module>
if not settings.DATABASES:
File "/usr/lib/python2.7/dist-packages/django/utils/functional.py", line 276, in __getattr__self._setup()
File "/usr/lib/python2.7/dist-packages/django/conf/__init__.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
And I'm not really sure what to do. These files are run in my django project folder, but including the settings file (via import settings) doesn't seem to fix this. What files should be included in order to import the right variables?
thanks!
Related
I use the Python distribution. Python 2.7 x64 with Windows 7 SP1 x64 Ultimate.
After a conda update --all, whenever I try to import matplotlib.pyplot I get ImportError: DLL load failed: %1 is not a valid Win32 application.. Why?
Full error stack:
Traceback (most recent call last):
File "C:\svn\hw4\code\test_con.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Anaconda\lib\site-packages\matplotlib\pyplot.py", line 109, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "C:\Anaconda\lib\site-packages\matplotlib\backends\__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "C:\Anaconda\lib\site-packages\matplotlib\backends\backend_qt4agg.py", line 17, in <module>
from .backend_qt5agg import NavigationToolbar2QTAgg
File "C:\Anaconda\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 18, in <module>
from .backend_qt5 import QtCore
File "C:\Anaconda\lib\site-packages\matplotlib\backends\backend_qt5.py", line 31, in <module>
from .qt_compat import QtCore, QtGui, QtWidgets, _getSaveFileName, __version__
File "C:\Anaconda\lib\site-packages\matplotlib\backends\qt_compat.py", line 91, in <module>
from PyQt4 import QtCore, QtGui
ImportError: DLL load failed: %1 is not a valid Win32 application.
I had the same issue after running conda update anaconda. The solution that worked for me was to simply to download the latest windows installer, then uninstall and reinstall.
I suspect this is related to the pathname of your conda environment, as if you do a clean install anaconda now wants to live in C:\Users\yourname\AppData\Local\Continuum\Anaconda2, where previously it was just Anaconda (no 2). I suspect after running the upgrade scripts some things are pointing to the nonexistant (for you) "new" path.
I found that if I explicitly activate a conda environment with activate myenvname before running anything it works fine. Likewise if you you run from the "anaconda prompt" (which activates your default environment for you) it works fine. But to get my default environment to stay active from anywhere like its supposed to I had to reinstall.
Here is what worked for me:
Run conda update -f matplotlib (from the Anaconda command prompt)
This gave me a new error:
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
File "C:\svn\hw4\code\test_con.py", line 1, in <module>
import matplotlib.pyplot
File "C:\Anaconda\lib\site-packages\matplotlib\pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "C:\Anaconda\lib\site-packages\matplotlib\colorbar.py", line 32, in <module>
import matplotlib.artist as martist
File "C:\Anaconda\lib\site-packages\matplotlib\artist.py", line 12, in <module>
from .transforms import Bbox, IdentityTransform, TransformedBbox, \
File "C:\Anaconda\lib\site-packages\matplotlib\transforms.py", line 39, in <module>
from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
ImportError: numpy.core.multiarray failed to import
Run conda update -f numpy
This gave me a new error:
Traceback (most recent call last):
File "C:\svn\hw4\code\test_con.py", line 1, in <module>
import matplotlib.pyplot
File "C:\Anaconda\lib\site-packages\matplotlib\pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "C:\Anaconda\lib\site-packages\matplotlib\colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "C:\Anaconda\lib\site-packages\matplotlib\collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "C:\Anaconda\lib\site-packages\matplotlib\backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "C:\Anaconda\lib\site-packages\matplotlib\textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "C:\Anaconda\lib\site-packages\matplotlib\mathtext.py", line 63, in <module>
import matplotlib._png as _png
ImportError: DLL load failed: The specified module could not be found.
Run conda install anaconda. This rolled your system back to a stable anaconda distribtution, and solved the issue. (I guess you could skip steps 1 and 2, but I don't feel like going through it again to confirm…)
So I without thinking stupidly named a file io.py in my working directory. When I tried to compile I got a traceback error. Having realised what I'd done I renamed my file and updated references to it but I still get the following error:
Traceback (most recent call last):
File "C:\Users\Tom\workspace\Converter\get_file.py", line 9, in <module>
from scipy import complex_
File "C:\Python27\lib\site-packages\scipy\__init__.py", line 70, in <module>
from numpy import show_config as show_numpy_config
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 185, in <module>
from . import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 46, in <module>
from numpy.testing import Tester
File "C:\Python27\lib\site-packages\numpy\testing\__init__.py", line 13, in <module>
from .utils import *
File "C:\Python27\lib\site-packages\numpy\testing\utils.py", line 15, in <module>
from tempfile import mkdtemp
File "C:\Python27\lib\tempfile.py", line 32, in <module>
import io as _io
File "C:\Users\Tom\workspace\Converter\io.py", line 1, in <module>
"""The io module provides the Python interfaces to stream handling. The
File "C:\Users\Tom\workspace\Converter\get_file.py", line 9, in <module>
from scipy import complex_
ImportError: cannot import name complex_
I have restarted PyDev to no avail. I have refreshed the interpreter to no avail.
I have followed the instructions found in this Python issue but that command returns the correct result on my machine.
Is tempfile.py a temporary file I can remove to resolve this issue?
I have found the solution. Stupidly simple but maybe worth leaving here for other newbies who fall into the same trap.
PyDev compiles the code into *.pyc files. When you update the references and rename the files these aren't immediately recompiled. Deleting the io.pyc file I had allowed compilation too run properly.
I found some more info on common pitfalls too.
I am attempting to run the DatastoreWordCountExample from the Dataflow SDK.
The instructions indicate that I should run the following commands:
$ export CLOUDSDK_EXTRA_SCOPES=https://www.googleapis.com/auth/datastore
$ gcloud auth login
However, when I do, I receive the following error:
$ export CLOUDSDK_EXTRA_SCOPES=https://www.googleapis.com/auth/datastore
$ gcloud auth login
Traceback (most recent call last):
File "/Users/brian/opt/google-cloud-sdk/./lib/googlecloudsdk/gcloud/gcloud.py", line 91, in <module>
from googlecloudsdk.calliope import base
File "/Users/brian/opt/google-cloud-sdk/./lib/googlecloudsdk/calliope/base.py", line 8, in <module>
from googlecloudsdk.calliope import usage_text
File "/Users/brian/opt/google-cloud-sdk/./lib/googlecloudsdk/calliope/usage_text.py", line 12, in <module>
from googlecloudsdk.calliope import arg_parsers
File "/Users/brian/opt/google-cloud-sdk/./lib/googlecloudsdk/calliope/arg_parsers.py", line 42, in <module>
from googlecloudsdk.core import log
File "/Users/brian/opt/google-cloud-sdk/./lib/googlecloudsdk/core/log.py", line 12, in <module>
from googlecloudsdk.core import properties
File "/Users/brian/opt/google-cloud-sdk/./lib/googlecloudsdk/core/properties.py", line 10, in <module>
from googlecloudsdk.core import config
File "/Users/brian/opt/google-cloud-sdk/./lib/googlecloudsdk/core/config.py", line 293, in <module>
_CheckForExtraScopes()
File "/Users/brian/opt/google-cloud-sdk/./lib/googlecloudsdk/core/config.py", line 291, in _CheckForExtraScopes
CLOUDSDK_SCOPES.extend(extra_scopes.split())
AttributeError: 'tuple' object has no attribute 'extend'
Note that gcloud runs find as long as CLOUDSDK_EXTRA_SCOPES is unset in my environment variables.
According to https://code.google.com/p/google-cloud-sdk/issues/detail?id=128 it seems that you no longer need to set this variable for datastore to work. Can you please try that and tell us if it doesn't work?
(meanwhile I'll update the docs)
I receive the following error when trying to run a shell command using Python Tool for Visual Studio. I have added the database to the settings file, and have been able to run the django app without errors, but when I try to add data using the shell, it throws this error:
>>> from ProjectTrackerServer.projects.models import Project
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\djangoapps\ProjectTrackerServer\ProjectTrackerServer\projects\models.py", line 1, in <module>
from django.db import models
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 11, in <module>
if DEFAULT_DB_ALIAS not in settings.DATABASES:
File "C:\Python27\lib\site-packages\django\utils\functional.py", line 184, in inner
self._setup()
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 40, in _setup
raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
The error states the issue. It occurred because you forgot to supply the project setting DJANGO_SETTINGS_MODULE. You can fix it by supplying it. You need to set the DJANGO_SETTINGS_MODULE environment variable.
When you use Django, you have to tell it which settings
you're using. Do this by using an environment variable,
DJANGO_SETTINGS_MODULE.
The value of DJANGO_SETTINGS_MODULE should be in
Python path syntax, e.g. mysite.settings. Note
that the settings module should be on the
Python import search path.
https://docs.djangoproject.com/en/dev/topics/settings/
When attempting to set this up, I am encountering the following error:
Traceback (most recent call last):
File "manage.py", line 11, in <module>
import settings
File "/Users/Paul/Documents/shopifywarrantymanager/settings.py", line 7, in <module>
from djangoappengine.settings_base import *
File "/Users/Paul/Documents/shopifywarrantymanager/djangoappengine/settings_base.py", line 6, in <module>
setup_env()
File "/Users/Paul/Documents/shopifywarrantymanager/djangoappengine/boot.py", line 64, in setup_env
setup_project()
File "/Users/Paul/Documents/shopifywarrantymanager/djangoappengine/boot.py", line 114, in setup_project
from .utils import have_appserver, on_production_server
File "/Users/Paul/Documents/shopifywarrantymanager/djangoappengine/utils.py", line 12, in <module>
appconfig, unused = dev_appserver.LoadAppConfig(PROJECT_DIR, {})
ValueError: too many values to unpack
I have not altered the files in any way other than adding my API key/shared secret, and changing the application name in 'app.yaml' to the one I registered with GAE.
I think you are using an old version of Djangoappengine.
The method LoadAppConfig since SDK 1.6 returns a tuple of three values (AppInfoExternal, URLMatcher, from_cache); the code in utils.py is wrong because is expecting just two values from it.
If you look into a more updated version of Djangoappengine you can see that the method is correctly called:
appconfig = dev_appserver.LoadAppConfig(PROJECT_DIR,
{},
default_partition='dev')[0]