Not able to install Django on windows 7 - python

I am trying to install Django-1.5.5 on windows 7. I have installed it but when I try to punch in "django-admin.py startproject mysite" I get following error:
C:\Users\DIPANSHU>django-admin.py startproject mysite
Traceback (most recent call last):
File "C:\Django-1.5.5\django\bin\django-admin.py", line 2, in <module>
from django.core import management
File "C:\Python27\lib\site-packages\django\core\management\__init__.py",
9, in <module>
from django.core.management.base import BaseCommand, CommandError, han
fault_options
File "C:\Python27\lib\site-packages\django\core\management\base.py", lin
in <module>
from django.utils.encoding import force_str
File "C:\Python27\lib\site-packages\django\utils\encoding.py", line 10,
dule>
from urllib import quote
File "C:\Python27\lib\urllib.py", line 26, in <module>
import socket
File "C:\Python27\lib\socket.py", line 47, in <module>
import _socket
ImportError: DLL load failed: The specified procedure could not be found.
Previously, I tried with Django-1.4.2 but problem was same. I am having Python27.Please assist.

Yups! Finally got it! So here's what I did:
Removed python completely and installed it again.
adjust my PATH environment variable to include paths to the Python executable & additional scripts.
Installed Setuptools
Installed pip using easy_install pip.
Installed Django using pip install django.
Note: If your Python is installed in C:\Python27\, the following paths need to be added to PATH: C:\Python27\;C:\Python27\Scripts;
Reference: https://docs.djangoproject.com/en/dev/howto/windows/
Thanks a lot for your valuable inputs and bearing with me! :-)

I would make sure that DJango is installed by running
python -c "import django; print(django.get_version())"
https://docs.djangoproject.com/en/1.6/intro/tutorial01/
I found the Django tutorial on their site to be very good
Also what exactly are you typing into the command prompt ? You should simply be in directory C:\Users\DIPANSHU> in the command shell
EDIT: you should be in the directory where you installed Django

Related

No user_config.py

We have an internal wiki and I want to use pywikibot to get some data from it. Installed it from pip but when I import it I get:
>>> import pywikibot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/site-packages/pywikibot/__init__.py",
line 25, in <module>
from pywikibot.bot import (
File "/usr/local/lib/python3.7/site-packages/pywikibot/bot.py", line
105, in <module>
from pywikibot import config2 as config
File "/usr/local/lib/python3.7/site-packages/pywikibot/config2.py",
line 373, in <module>
base_dir = get_base_dir()
File "/usr/local/lib/python3.7/site-packages/pywikibot/config2.py",
line 367, in get_base_dir
raise RuntimeError(exc_text)
RuntimeError: No user-config.py found in directory '/vagrant'.
Looking here https://www.mediawiki.org/wiki/Manual:Pywikibot/Installation#Configure_Pywikibot
I see a reference to pwb.py, but that does not exist in
/usr/local/lib/python3.7/site-packages/pywikibot.
What am I missing here?
Thanks!
Installing pywikibot from pip currently only installs the library part. The pwb.py and related console scripts are not included in the PyPI package. That means that you'll need to create the user-config.py manually or download the scripts in some other way.
I believe most pywikibot users just clone the git repo. The general process would be something like this:
git clone https://github.com/wikimedia/pywikibot.git --depth 1
python3 -m pip install -U setuptools
python3 -m pip install -e pywikibot/
cd pywikibot/
python3 pwb.py generate_family_file.py https://url.to.your/wiki/api.php? mywikiname
python3 pwb.py generate_user_files.py
# follow the prompts
Adding generate_family_file is in active development:
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/634544
The other two script will follow later I guess.

trouble loading jedi-vim after install

My issue is possibly similar to link
but thought I'd ask jic. I'm on osx and trying to use jedi-vim. I installed jedi using pip and then jedi-vim by cloning into the dir that my vim config uses for loading packages. this one for reference. When I start vim with a python program I get the "Please install Jedi if..." message. I cloned vim 74 and configured with +python and +conceal. After still getting the error I looked into the code and found it was an import error.
As an aside, this isn't the best help message. Better might be "Unable to import jedi. Have you installed Jedi?"
I tried import jedi from within vim, as :python import jedi
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/jedi-0.9.0- py2.7.egg/jedi/__init__.py", line 41, in <module>
from jedi.api import Script, Interpreter, NotFoundError, set_debug_function
File "/usr/local/lib/python2.7/site-packages/jedi-0.9.0 py2.7.egg/jedi/api/__init__.py", line 16, in <module>
from jedi.parser import Parser, load_grammar
File "/usr/local/lib/python2.7/site-packages/jedi-0.9.0-py2.7.egg/jedi/parser/__init__.py", line 21, in <module>
from jedi.parser import tree as pt
ImportError: cannot import name tree
If this is a build issue, is there a good reference for building vim on mac?

Django: ImportError: cannot import name _compare_digest

I have installed Django 1.6.5 with PIP and Python 2.7.8 from the website.
I ran django-admin.py startproject test123, switched to test123 directory, and ran the command python manage.py runserver, then i get this:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/conf/__init__.py", line 50, in _setup
self._configure_logging()
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/conf/__init__.py", line 72, in _configure_logging
from django.utils.log import DEFAULT_LOGGING
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/utils/log.py", line 7, in <module>
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/views/debug.py", line 10, in <module>
from django.http import (HttpResponse, HttpResponseServerError,
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/http/__init__.py", line 2, in <module>
from django.http.request import (HttpRequest, QueryDict, UnreadablePostError,
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/http/request.py", line 11, in <module>
from django.core import signing
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/signing.py", line 45, in <module>
from django.utils.crypto import constant_time_compare, salted_hmac
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/utils/crypto.py", line 6, in <module>
import hmac
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 8, in <module>
from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
Found out that operator is a standard python library. Why cant it not import it?
P.S. I did try it in the command line, I can import the operator module, but I get an error on this statement: from operator import _compare_digest as compare_digest
Followed this SO answer:
Uninstall python.org version of python2.7 in favor of default OS X python2.7
Then changed my .bash_profile Python path to /usr/lib/python for the default OSX python path.
Uninstalled Django and MySQL-Python:
sudo pip uninstall django
sudo pip uninstall MySQL-Python
And then again reinstalled everything, but with MySQL-Python being the first and second Django.
After these steps, everything is working.
I get this error with anaconda as my default python and django1.7 while trying to use startproject.
I deleted the venv and recreated it with
virtualenv -p /usr/bin/python2.7 venv
startproject was working again.
You most likely have another file named operator.py on your PYTHONPATH (probably in the current working directory), which shadows the standard library operator module..
Remove or rename the file.
For those not wanting to switch to Apple's python, simply deleting the virtualenv and rebuilding it worked fine for me.
Tip: Don't forget to pip freeze > requirements.txt first if you aren't already tracking your package requirements. That way you can pip install -r requirements.txt to get up and running again quickly.

No module named profile

when i tried to search bookdetails from library of congress using python with the help of z3950 module, I got following error
from PyZ3950 import zoom
File "/usr/local/lib/python2.6/dist-packages/PyZ3950/zoom.py", line 72, in <module>
from PyZ3950 import z3950
File "/usr/local/lib/python2.6/dist-packages/PyZ3950/z3950.py", line 72, in <module>
from PyZ3950 import asn1
File "/usr/local/lib/python2.6/dist-packages/PyZ3950/asn1.py", line 2009, in <module>
import profile
ImportError: No module named profile
please help me for a solution
This blog post suggests that it is not part of the default install of Python on Ubuntu 11.04. It says:
You will need to enable the multiverse repository first.
The solution is to install the python-profiler package, i.e. do this command:
sudo aptitude install python-profiler
Then you can use python profile as normal.

Django throws an ImportError on Mac OS X

I'm trying to get a work project that I git-cloned from work (used in numerous other places, I know the project works fine) to run on my MacBook. I installed Django (via sudo python setup.py install), as well as MySQL, the Python MySQL wrapper, and also virtualenv with virtualenvwrapper.
After creating a virtualenv for my project (virtualenv is created fine), and doing a pip install for the project requirements (all of which install into the proper virtualenv directory), an attempt to do a runserver command spits out the following:
Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_manager(settings)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 436, in execute_manager
setup_environ(settings_mod)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 419, in setup_environ
project_module = import_module(project_name)
File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named website-backend
First try to import this library from python or ./manage.py shell.
If that fails import sys and check if your lib is in sys path print sys.path

Categories