I am not able to run python manage.py shell, I am getting the following exception:
[root#dd dase]# python manage.py shell
Error: cannot import name six
But six is installed on the server:
[root#dd dase]# python
Python 2.6.6 (r266:84292, Jun 18 2012, 14:18:47)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import six
>>> six.__version__
'1.9.0'
Django Version:
[root#dd dase]# django-admin --version
1.2.7
Nothing in traceback:
[root#dd dase]# python manage.py shell --traceback
Error: cannot import name six
Could be a package you have installed that's trying to use django.utils.six which became available in 1.4.2 (No module named six). Definitely upgrade your django version as given above.
Related
I have been using lirc in Python 2.7 and Python 3.5.3 on Rpi3. Now I have installed Python 3.8.7 from source code, but I am not able to use lirc in this version of Python, but it still works in Python 3.5. apt-get reports that python3-lirc is already the newest version (1.2.1-2). How to get lirc work in both Python 3.5 and 3.8?
pi#RPi3:~ $ python
Python 3.8.7 (default, Jan 7 2021, 08:59:27)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lirc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'lirc'
>>>
pi#RPi3:~ $ python3.5
Python 3.5.3 (default, Nov 18 2020, 21:09:16)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lirc
>>> sockid=lirc.init("myProg", blocking = False)
>>>
It means that you installed lirc on only one of the two pythons.
Use the pip from your Python 3.8 to install lirc so that the module will also be accessible to your Python 3.8.
Module lirc has to be uninstalled with pip, then python-lirc can be installed in Python 3,8 as described in https://github.com/tompreston/python-lirc/issues/26 after installing cyhton with pip.
I downloaded and installed (build + make) a cython package, g2opy successfully. And when I tried checking if everything went well, I get this:
(cv) clmno#machine:~/OpenSource/python/g2opy$ python
Python 3.4.5 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:47:47)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import g2o
>>> import numpy
>>> import cv2
So, I assume everything is fine and opened another terminal window. And tried importing the same module, but failed:
(cv) clmno#machine:~$ python
Python 3.4.5 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:47:47)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import g2o
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'g2o'
Has this to do with the shared library (.so file)? If it was successfully imported, why would it fail the next time?
In the second terminal, you are running Python in a different directory compared to the first terminal. This suggests that the library you built is not in the Python path. It worked in the first terminal because the g2o library is in the directory where you are currently running Python. As Matthieu suggested, add "~/OpenSource/python/g2opy" to your PYTHONPATH environment variable.
In ~/.bashrc, add:
export PYTHONPATH=$PYTHONPATH:path/to/g2opy
then run source ~/.bashrc to update the environment variable in the current path.
If you installed the package locally, you need to set PYTHONPATH. Seems like it's not set properly.
I have python installed in two locations, in os default it's 2.6.6 and in /usr/local/bin/python2.7 has 2.7.
I have installed cairo (cairo-1.12.18) via source using configure/make/make install, but it appears to have installed under python 2.6.6. How do I install it for python2.7?
[root#xxxxx ~]# python
Python 2.6.6 (r266:84292, Oct 12 2012, 14:23:48)
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cairo
>>>
[root#xxxxx ~]# /usr/local/bin/python2.7
Python 2.7.8 (default, Nov 18 2014, 11:15:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cairo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cairo
>>>
Thank you.
Be sure to install it using python 2.7 and not python 2.6 (run make and make install using python 2.7). I assume you use Linux OS so your default Python is 2.7, you can change your default Python but it's not recommended due to several reasons. Please look at this StackOverflow question and answers for more informations:
Two versions of python on linux. how to make 2.7 the default
I'm new to Ubuntu (14.04). I just installed django using sudo pip install Django.
This is what is happening:
rpr#rpr-Inspiron-3521:~$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>>
rpr#rpr-Inspiron-3521:~$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'django'
>>>
What should I do to be able to use Django from Python3.4?
Just write:
sudo pip3 install Django
But better use virtualenv like Daniel said.
Reference
If you cannot run pip3 install it with the following:
sudo apt-get install python3-setuptools
sudo easy_install3 pip
pip is presumably installed for Python 2, not Python 3. You may have a version named pip3 that targets Py3.
However, it would be better to use a virtualenv.
I am using MacOS X 10.7.5 and am a TOTAL newb at Python
I am pretty sure django installed correctly as per https://code.djangoproject.com/wiki/Distributions
$ sudo port install py27-django
---> Computing dependencies for py27-django
---> Cleaning py27-django
---> Scanning binaries for linking errors: 100.0%
---> No broken files found.
$ python
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
The issue was with that a prior Python was installed (2.7.1) previously and MacPorts installed a new one (2.7.6) but did not update the Mac Sym links etc
So I had to futz with my PATH
$ vi ~/.bash_profile
.
.
export PATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH
.
.
$ source ~/.bash_profile
$ python --version
Python 2.7.6
$ python
Python 2.7.6 (default, Nov 12 2013, 13:12:10)
[GCC 4.2.1 Compatible Apple Clang 4.1 ((tags/Apple/clang-421.11.66))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print django.get_version()
1.5.1