I am trying to get Django running on a shared hosting account for which I have ssh access, but I have been having issues getting it working. When I first tried running django-admin.py, I received an error about the module 'functools' being missing. I had the hosting company install the functools package, but now I get the following traceback when I try to run django-admin.py.
Traceback (most recent call last):
File "manage.py", line 2, in <module>
from django.core.management import execute_manager
File "/usr/local/lib/python2.6/site-packages/Django-1.3-py2.6.egg/django/core/management/__init__.py", line 3, in <module>
from optparse import OptionParser, NO_DEFAULT
File "/usr/local/lib/python2.6/optparse.py", line 90, in <module>
from gettext import gettext
File "/usr/local/lib/python2.6/gettext.py", line 49, in <module>
import locale, copy, os, re, struct, sys
File "/usr/local/lib/python2.6/locale.py", line 98, in <module>
#functools.wraps(_localeconv)
AttributeError: 'module' object has no attribute 'wraps'
I opened a support ticket and was told by the company that they reinstalled Python 2.6, but that didn't change anything. I also tried with 2.4, which is also installed on the machine, but that resulted in the earlier ImportError: No module named functools error.
Does anybody have any ideas?
A likely cause is something shadowing the stdlib functools module. Do you have a functools.py alongside the main script (manage.py)? See what import functools; print functools.__file__ prints, inside manage.py (before any of the other imports.) If it doesn't print /usr/local/lib/python2.6/functools.py, there's probably a file shadowing the standard library module. If it does print that, something is wrong with that file, reinstalls notwithstanding.
this solution worked for me .
mv /usr/lib/python2.7/site-packages/pip* ./
yum reinstall python-pip
sudo pip install django
or try an another solution .
its too risky and this might not be a safest solution.but it worked fine for me .
uninstall pip.
pip uninstall pip
if you installed by get-pip.py .
python -m pip uninstall pip setuptools
navigate to the path.
/usr/lib/python2.7/site-packages/
and find out two pip directories pip and pip-6.0.8.dist-info.
remove both pip and pip-6.0.8.dist-info.
then try again.
yum install python-pip
or
python get-pip.py
Related
I am not able to install the bz2 package in Python 3 Can please anyone guide
I followed the below commands
sudo yum install bzip2-devel
after that, I start my python 3.7 terminal and use the below command
import bz2
The error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/sysopt/lib/python3.7/bz2.py", line 19, in <module>
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
Based on the comments and the /usr/local/sysopt path, I assume you've installed Python 3.7 from a source package.
When you did that, the Python configure script checked whether it has the bits to compile the bz2 module, and as you didn't have bzip2-devel installed during that time, the builtin bz2 module didn't get compiled.
You will need to recompile and reinstall Python 3.7 to get it included. At that point, you may also want to pay heed to any other optional modules that inadvertently don't get installed; sqlite3 tends to usually be one that ends up missing!
I am trying to install django-adim-tools using pip, but this is what happens:
C:\Users\hugo.villalobos>pip install django-admin-tools
Could not import runpy module
Traceback (most recent call last):
File "C:\Python34\Lib\runpy.py", line 14, in <module>
import importlib.machinery # importlib first so we can test #15386 via -m
File "C:\Python34\Lib\importlib\__init__.py", line 34, in <module>
_w_long = _bootstrap._w_long
AttributeError: module 'importlib._bootstrap' has no attribute '_w_long'
I have no idea how to proceed to solve it.
In my case, I have multiple Python (3.7, 3.6, 3.4) installed in my PC. The environment var $PATH and $PYTHONPATH is pointing to different version's. After resetting these 2 environment vars correctly everything runs correctly then.
had similar issue running the command:
pipenv install --python 3.8
solved by removing python3.8 from environment variable $PATH, and keeping only 3.7 as default python:
C:\Users\MB\AppData\Local\Programs\Python\Python37\Scripts\
C:\Users\MB\AppData\Local\Programs\Python\Python37\
I have apache ampps which comes with version 3.6.1 of python.
I was given various directions for installing pip.
None seemed to work.
For example,
link https://packaging.python.org/tutorials/installing-packages/
says that I can run:
python -m pip install -U pip setuptools
Get a whole bunch of errors. It might amount to: no module named queue.
Similar errors happen when I download the file they mentioned (get-pip.py) and run it from python.
Now, when I look at directions for installing queue, some point me to use pip. But when I try to install pip, it is complaining that queue is not there....
Hmmm...?
Now what?
ERROR:
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\compat\__init__.py", line 11, in <module>
File "C:\Program Files (x86)\Ampps\python\lib\logging\config.py", line 30, in <module>
import logging.handlers
File "C:\Program Files (x86)\Ampps\python\lib\logging\handlers.py", line 28, in <module>
import queue
ModuleNotFoundError: No module named 'queue'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "getpip.py", line 20061, in <module>
main()
File "getpip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "getpip.py", line 82, in bootstrap
import pip
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\__init__.py", line 26, in <module>
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\utils\__init__.py", line 22, in <module>
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\compat\__init__.py", line 13, in <module>
File "C:\Users\Nima\AppData\Local\Temp\tmp1v2hpnae\pip.zip\pip\compat\dictconfig.py", line 22, in <module>
File "C:\Program Files (x86)\Ampps\python\lib\logging\handlers.py", line 28, in <module>
import queue
ModuleNotFoundError: No module named 'queue'
From the format i see here.
Firstly, pip is an installer basically what you've confused yourself with is that pip = queue which is not the case. Pip is just a packager that helps you install packages. Queue is a different module
For your case here Queue is a part of multiprocessing module so you just put this at the top of your code:
from multiprocessing import Queue
and you do not need to add import pip into your code
hope that explained things better for you :)
This line:
python -m pip install -U pip setuptools
means use pip to upgrade the installations of pip and setuptools. Only works if you already have pip - which you probably do. It is a useful step to make sure your install environment is up to date, though.
pip does in places use queue. Note it's been renamed between python2 and python3 - if you have py3, which you claim, you have queue (it was Queue in py2). So I wonder if there's a version mismatch in something.
Windows installs always create problems. You might be safer installing and experimenting with a virtualenv so your experiments don't mess up the python install from the package you mention - ampps. There are plenty of notes on that elsewhere on stackoverflow... e.g. Python and Virtualenv on Windows
pip is already included in 3.6.1, but it is in subfolder Scripts.
it is not automatically a part of the path variable.
you have to change directory and run pip or you can change environment variable so that the location of pip becomes part of the path search.
After I pulled dynamic-dynamodb via git and made my changes to example-dynamic-dynamodb.conf and install the requirements.txt,
I am trying to run/start dynamic-dynamodb
I am running on AWS EC2
OS: ubuntu 14.04
python --version Python 2.6.9
pip --version pip 7.1.2 from /usr/local/lib/python2.6/site-packages (python 2.6)
$>cd dynamic-dynamodb
$>ls
build cloudformation-templates dist docs dynamic_dynamodb dynamic-dynamodb dynamic_dynamodb.egg-info example-dynamic-dynamodb.conf LICENSE Makefile MANIFEST MANIFEST.in README README.md requirements.txt setup.py
$>./dynamic-dynamodb start
Traceback (most recent call last):
File "./dynamic-dynamodb", line 22, in <module>
import dynamic_dynamodb
File "/root/dynamic-dynamodb/dynamic_dynamodb/__init__.py", line 29, in <module>
from dynamic_dynamodb.aws import dynamodb
File "/root/dynamic-dynamodb/dynamic_dynamodb/aws/dynamodb.py", line 12, in <module>
from dynamic_dynamodb.log_handler import LOGGER as logger
File "/root/dynamic-dynamodb/dynamic_dynamodb/log_handler.py", line 26, in <module>
import config_handler
File "/root/dynamic-dynamodb/dynamic_dynamodb/config_handler.py", line 5, in <module>
CONFIGURATION = config.get_configuration()
File "/root/dynamic-dynamodb/dynamic_dynamodb/config/__init__.py", line 155, in get_configuration
'tables': ordereddict()
TypeError: 'module' object is not callable
Is this the right way to start dynamic-dynamodb service?
Dose any one have an advice?
This looks like a bug in dynamic-dynamodb.
In dynamic_dynamodb/config/config_file_parser.py and dynamic_dynamodb/config/__init__.py, there is code like:
try:
from collections import OrderedDict as ordereddict
except ImportError:
import ordereddict
ImportError is caught when you're using a version lower than 2.7, and collections.OrderedDict doesn't exist. But doing just import ordereddict seems like a logical error; you want ordereddict to point to the OrderedDict class, not the module that contains the OrderedDict class.
First, I suggest upgrading to 2.7 or higher, where this is no longer a problem.
Second, If you can't do that, I suggest changing the lines in both of those files to
try:
from collections import OrderedDict as ordereddict
except ImportError:
from ordereddict import OrderedDict as ordereddict
Third, if that doesn't work, I suggest filing a bug on the github page, and hopefully the author will issue a fix. (actually, you should probably do this regardless of whether the previous two approaches succeed)
I had the same issue, it looks like this is all due to the current t1.micro instance does not come updated with Python 2.7, and pip cannot install dynamic-dynamodb package without it. So I tried to update all in sequence and it worked for me, I have tried a couple times and missing any of these steps or out of order would not work.
sudo yum update
sudo update-alternatives --set python /usr/bin/python2.7
sudo easy_install pip
sudo /usr/local/bin/pip install -U dynamic-dynamodb
I am on Ubuntu 13.04. I get the following error message -
Traceback (most recent call last):
File "analyse.py", line 1, in <module>
from log import shelve
File "/home/shubham/SMART/TaxiData/log.py", line 27, in <module>
from demo import *
File "/home/shubham/SMART/zones/demo.py", line 5, in <module>
from qgis.core import *
ImportError: No module named qgis.core
Actually, everything was working fine till today morning. I guess this might be due to a package update.
I tried looking around on Google but my search was fruitless. So, I will really appreciate any help or pointers you guys can give :)
Thanks.
I solved the problem by completely removing the installation and using the nightly builds at 'deb http://qgis.org/debian-nightly raring main'.
If you have pip installed you could either try pip search qgis or pip freeze. The latter shows a list of all installed python packages to check if you have the package. Maybe try reinstalling qgis ...
Try sudo apt-get install python-qgis . The package does not appear to be available on PyPI, but it was listed as "python-qgis" in the Ubuntu packages.