I have been using django perfectly sans problems until today. It was giving me the error on an existing project but I have recently tried to create a new project and I stil get the same errors.
I am on ubuntu 14.04, django 1.7, I use virtualenv and python 3 (alhtough I have tried using a python2 env also).
I get this error:
ubuntuuser#computer:~/tmp$
ubuntuuser#computer:~/tmp$ mkvirtualenv djerror
New python executable in djerror/bin/python
Installing setuptools, pip...done.
cd (djerror)ubuntuuser#computer:~/tmp$ cd borrar/
bin/ borrar/ include/ lib/ local/
(djerror)ubuntuuser#computer:~/tmp$ django-admin.py startproject djerror
(djerror)ubuntuuser#computer:~/tmp$ cd djerror/
(djerror)ubuntuuser#computer:~/tmp/djerror$ ls
djerror manage.py
(djerror)ubuntuuser#computer:~/tmp/djerror$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 1, in <module>
import collections
File "/usr/local/lib/python3.4/collections/__init__.py", line 17, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/usr/local/lib/python2.7/dist-packages/reprlib.py", line 3, in <module>
from repr import *
ImportError: No module named 'repr'
(djerror)ubuntuuser#computer:~/tmp/djerror$
here is another method which gfives me the same error:
ubuntuuser#computer:~/tmp$ virtualenv djerror2
New python executable in djerror2/bin/python
Installing setuptools, pip...done.
ubuntuuser#computer:~/tmp$ cd djerror
ubuntuuser#computer:~/tmp/djerror$ cd ..
ubuntuuser#computer:~/tmp$ cd djerror2
ubuntuuser#computer:~/tmp/djerror2$ . bin/activate
(djerror2)ubuntuuser#computer:~/tmp/djerror2$ pip list
awsebcli (3.0.10)
cement (2.4.0)
Django (1.7.5)
django-bootstrap3 (5.1.1)
django-braces (1.4.0)
...
stevedore (1.2.0)
virtualenv (12.0.6)
virtualenv-clone (0.2.5)
virtualenvwrapper (4.3.2)
(djerror2)ubuntuuser#computer:~/tmp/djerror2$ django-admin.py startproject anothertest
(djerror2)ubuntuuser#computer:~/tmp/djerror2$ cd anothertest/
(djerror2)ubuntuuser#computer:~/tmp/djerror2/anothertest$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 1, in <module>
import collections
File "/usr/local/lib/python3.4/collections/__init__.py", line 17, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/usr/local/lib/python2.7/dist-packages/reprlib.py", line 3, in <module>
from repr import *
ImportError: No module named 'repr'
(djerror2)ubuntuuser#computer:~/tmp/djerror2/anothertest$
What gives?
edit:
This is what I have at the bottom of ~/.bashrc. I have done some changes ever since I installed ubuntu, but I recently changed the bottom two lines for virtualenvwrapper.
alias python='python3'
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
I think the rest of the file is untouched.
After some fiddling around (and especially after reading Brandon and Daniel's comments) I spotted the problem.
I had done something wrong at some point in time which wasn't causing problems until today. The thing is python was loading some modules from the python2 path and others from the python3 path.
To fix it I did the following:
remove the python3 alias
to do this correctly you have to rm python from /usr/bin/ and then point it to python3 sim link
purge remove python3 and reinstall it.
reinstall all packages associated to python3, like pip and others
Only then did everything work, though I may have gone overboard, I preferred to do it like this just to be sure.
Related
I am currently working with TurtleBot 2i, and I am just trying to install the GitHub repository.
I followed this link in order to install:
https://github.com/Interbotix/turtlebot2i/wiki/Full-Build-Instructions
Because I have previously installed Anaconda and installed some packages with Anaconda, I have removed:
export PATH="/home/sean/anaconda3/bin:$PATH"
from my .bashrc file.
The problem I have is that when I catkin_make my TurtleBot 2i folder, it gives me the following error:
[ 11%] Built target _turtlebot2i_block_manipulation_generate_messages_check_deps_PickAndPlaceResult
Traceback (most recent call last):
File "/opt/ros/kinetic/share/geneus/cmake/../../../lib/geneus/gen_eus.py", line 39, in <module>
import geneus
File "/opt/ros/kinetic/lib/python2.7/dist-packages/geneus/__init__.py", line 32, in <module>
from . geneus_main import *
File "/opt/ros/kinetic/lib/python2.7/dist-packages/geneus/geneus_main.py", line 43, in <module>
from catkin import terminal_color
File "/opt/ros/kinetic/lib/python2.7/dist-packages/catkin/terminal_color.py", line 2, in <module>
from catkin_pkg.terminal_color import * # noqa
ModuleNotFoundError: No module named 'catkin_pkg.terminal_color'
I typed:
dpkg -L python-catkin-pkg-modules
And this is what it gives me:
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/python-catkin-pkg-modules
/usr/share/doc/python-catkin-pkg-modules/copyright
/usr/share/doc/python-catkin-pkg-modules/changelog.Debian.gz
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/catkin_pkg
/usr/lib/python2.7/dist-packages/catkin_pkg/topological_order.py
/usr/lib/python2.7/dist-packages/catkin_pkg/metapackage.py
/usr/lib/python2.7/dist-packages/catkin_pkg/tool_detection.py
/usr/lib/python2.7/dist-packages/catkin_pkg/terminal_color.py
/usr/lib/python2.7/dist-packages/catkin_pkg/changelog_generator.py
/usr/lib/python2.7/dist-packages/catkin_pkg/__init__.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cmake.py
/usr/lib/python2.7/dist-packages/catkin_pkg/changelog_generator_vcs.py
/usr/lib/python2.7/dist-packages/catkin_pkg/templates
/usr/lib/python2.7/dist-packages/catkin_pkg/templates/CMakeLists.txt.in
/usr/lib/python2.7/dist-packages/catkin_pkg/templates/package.xml.in
/usr/lib/python2.7/dist-packages/catkin_pkg/templates/metapackage.cmake.in
/usr/lib/python2.7/dist-packages/catkin_pkg/python_setup.py
/usr/lib/python2.7/dist-packages/catkin_pkg/group_dependency.py
/usr/lib/python2.7/dist-packages/catkin_pkg/package_templates.py
/usr/lib/python2.7/dist-packages/catkin_pkg/workspace_vcs.py
/usr/lib/python2.7/dist-packages/catkin_pkg/package.py
/usr/lib/python2.7/dist-packages/catkin_pkg/group_membership.py
/usr/lib/python2.7/dist-packages/catkin_pkg/packages.py
/usr/lib/python2.7/dist-packages/catkin_pkg/changelog.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cli
/usr/lib/python2.7/dist-packages/catkin_pkg/cli/prepare_release.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cli/create_pkg.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cli/test_changelog.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cli/generate_changelog.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cli/tag_changelog.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cli/__init__.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cli/find_pkg.py
/usr/lib/python2.7/dist-packages/catkin_pkg/cli/package_version.py
/usr/lib/python2.7/dist-packages/catkin_pkg/package_version.py
/usr/lib/python2.7/dist-packages/catkin_pkg/condition.py
/usr/lib/python2.7/dist-packages/catkin_pkg/rospack.py
/usr/lib/python2.7/dist-packages/catkin_pkg/workspaces.py
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.8.egg-info
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.8.egg-info/top_level.txt
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.8.egg-info/dependency_links.txt
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.8.egg-info/PKG-INFO
/usr/lib/python2.7/dist-packages/catkin_pkg_modules-0.4.8.egg-info/requires.txt
I think this is some sort of catkin_pkg version problem, but I cannot figure out what the problem is.
I have tried to uninstall and install catkin_pkg through pip, but both failed.
Is there any way to solve this terminal_color error?
The output of env | grep PATH; env | grep ROSis the following:
ROS_PACKAGE_PATH=/home/sean/turtlebot2i/src:/opt/ros/kinetic/share
LD_LIBRARY_PATH=/home/sean/turtlebot2i/devel/lib:/opt/ros/kinetic/lib:/opt/ros/kinetic/lib/x86_64-linux-gnu
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
PATH=/home/sean/turtlebot2i/devel/bin:/opt/ros/kinetic/bin:/home/sean/bin:/home/sean/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
PYTHONPATH=/home/sean/turtlebot2i/devel/lib/python3/dist-packages:/opt/ros/kinetic/lib/python2.7/dist-packages
PKG_CONFIG_PATH=/home/sean/turtlebot2i/devel/lib/pkgconfig:/opt/ros/kinetic/lib/pkgconfig:/opt/ros/kinetic/lib/x86_64-linux-gnu/pkgconfig
CMAKE_PREFIX_PATH=/home/sean/turtlebot2i/devel:/opt/ros/kinetic
ROS_ROOT=/opt/ros/kinetic/share/ros
ROS_PACKAGE_PATH=/home/sean/turtlebot2i/src:/opt/ros/kinetic/share
ROS_MASTER_URI=http://localhost:11311
ROS_VERSION=1
ROS_HOSTNAME=sean-Lenovo-ideapad-Y700-17ISK
ROSLISP_PACKAGE_DIRECTORIES=/home/sean/turtlebot2i/devel/share/common-lisp
ROS_DISTRO=kinetic
ROS_ETC_DIR=/opt/ros/kinetic/etc/ros
I followed djangogirls tutorial to get started with django and had everything working. Once I finished the basic tutorial, everything in working order, I decided to go through the steps again to make something new and become more familiar with using git, django, venv, etc.
fyi - I am on windows 10 and have python 2.7 and python 3.5 installed. I am using python 3.5.2 with django 1.10.4.
steps:
>mkdir v2
>cd v2
>"d:/python 3.5.2/python" -m venv myenv
>cd myenv/scripts/activate
(myenv) python -m pip install -U pip
for some reason this is the only way I was able to upgrade pip this time around
(myenv) d:/v2/myenv/scripts> pip install django~=1.10.0
(myenv) d:/v2/myenv/scripts> django-admin.py startproject mysite
This is where the magic doesn't happen:
d:\v2>django-admin.py startproject mysite2
Traceback (most recent call last):
File "D:\v3\myenv\Scripts\django-admin.py", line 2, in <module>
from django.core import management
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 10, in <module>
from django.apps import apps
File "C:\Python27\lib\site-packages\django\apps\__init__.py", line 1, in <module>
from .config import AppConfig
File "C:\Python27\lib\site-packages\django\apps\config.py", line 4, in <module>
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
File "C:\Python27\lib\site-packages\django\core\exceptions.py", line 5, in <module>
from django.utils.encoding import force_text
File "C:\Python27\lib\site-packages\django\utils\encoding.py", line 11, in <module>
from django.utils.six.moves.urllib.parse import quote, unquote
File "C:\Python27\lib\site-packages\django\utils\six.py", line 92, in __get__
result = self._resolve()
File "C:\Python27\lib\site-packages\django\utils\six.py", line 160, in _resolve
module = _import_module(self.mod)
File "C:\Python27\lib\site-packages\django\utils\six.py", line 82, in _import_module
__import__(name)
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: Module use of python35.dll conflicts with this version of Python.
As far as I am aware, I followed the same steps. I am not sure why the djano installed in my venv would be referencing python 2.7, since I thought if created my venv from the python 3.5.2 dir it would reference that version, along with anything I used pip for within that dir?
Can someone help me find what I am missing here? ty.
By default virtualenv uses python2. If you want to use python3, you have to specify it explicitly.
Run following command to setup virtualenv with python3:
virtualenv -p python3 envname
While in "Python 3.5.2/scripts" I ran:
virtualenv d:/<dirname>
Everything after(django-admin.py startproject projectname) worked correctly. Still not sure what went wrong here but maybe this helps someone else...
Now we're developing our software on the customer side, and there is:
maestro#UIServer:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"
system is installed. We're not allowed to upgrade this system to a newer version, but we need to use Python 2.7 in our project.
E.g. we have to use pymorphy2 package, but when we're trying to import it into project, we get:
>>> import pymorphy2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/pymorphy2/__init__.py", line 3, in <module>
from .analyzer import MorphAnalyzer
File "/usr/local/lib/python2.7/site-packages/pymorphy2/analyzer.py", line 10, in <module>
from pymorphy2 import opencorpora_dict
File "/usr/local/lib/python2.7/site-packages/pymorphy2/opencorpora_dict/__init__.py", line 4, in <module>
from .storage import load_dict as load
File "/usr/local/lib/python2.7/site-packages/pymorphy2/opencorpora_dict/storage.py", line 24, in <module>
from pymorphy2.utils import json_write, json_read
File "/usr/local/lib/python2.7/site-packages/pymorphy2/utils.py", line 5, in <module>
import bz2
ImportError: No module named bz2
Ok, we're trying to install libbz2-dev:
sudo apt-get install libbz2-dev
end getting this:
ValueError: /usr/bin/python does not match the python default version. It must be reset to point to python2.6
dpkg: error processing python-pip (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
python-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)
How to avoid this problem?
Thanks in advance!
Download python, build and install using :
$ ./configure
$ make
$ make install
I am assuming you have build-essential installed or at least gcc. You can customize installation by passing prefix=/path/where/you/want/python/installed and other flags to make.
I have successfully created a virtual environment with virtualenvwrapper using python3 at /usr/local/bin/python3 as default interpreter. My system python is python2.7
I can't use pip3 in this virtual environment because it keeps looking inside the default /usr/lib/python2.7/dist-packages
(python3.3.3)╭ ➜ xxx#xxx:~VIRTUAL_ENV/bin
╰ ➤ pip3.3
Traceback (most recent call last):
File "/home/xxx/virtualenv/python3.3.3/bin/pip3.3", line 7, in <module>
from pip import main
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.basecommand import command_dict, load_command, load_all_commands, command_names
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 11, in <module>
from pip.baseparser import parser, ConfigOptionParser, UpdatingDefaultsHelpFormatter
File "/usr/lib/python2.7/dist-packages/pip/baseparser.py", line 5, in <module>
import pkg_resources
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 45
def _bypass_ensure_directory(name, mode=0777):
^
SyntaxError: invalid token
Am I forgetting something?
I've also tried to install python3 into a custom directory inside /opt but that doesn't help.
Got it. My system $PYTHONPATH contains /usr/lib/python2.7/dist-packages so I simply removed it from the path and everything is now working properly.
I wanted to start with some PyOpenGL, and so I booted into Mac Osx to try it. I went on the PyOpenGl website, downloaded the PyOpenGl and PyOpenGl_accelerate tars, cd'd into my downloads directory, and typed these commands into terminal to install:
tar -zxvf PyOpenGL-3.0.2.tar.gz
cd PyOpenGL-3.0.2
python3 setup.py install #I changed 'python' to 'python3' to install it to my python3.
next, i typed these to install the accelerate package
tar -zxvf PyOpenGL-accelerate-3.0.2.tar.gz
cd PyOpenGL-accelerate-3.0.2
python3 setup.py install #Again, 'python' replaced with 'python3'
Finally, I ran this code to test the install
python3
>>>from OpenGL.GL import *
which gave me this lovely string of errors
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/PyOpenGL-3.0.2-py3.3.egg/OpenGL/GL/__init__.py", line 3, in <module>
from OpenGL.GL.VERSION.GL_1_1 import *
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/PyOpenGL-3.0.2-py3.3.egg/OpenGL/GL/VERSION/GL_1_1.py", line 10, in <module>
from OpenGL import platform, constants, constant, arrays
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/PyOpenGL-3.0.2-py3.3.egg/OpenGL/arrays/__init__.py", line 19, in <module>
from OpenGL.arrays.arraydatatype import *
File "/usr/local/Cellar/python3/3.3.0/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/PyOpenGL-3.0.2-py3.3.egg/OpenGL/arrays/arraydatatype.py", line 14, in <module>
from OpenGL_accelerate.arraydatatype import ArrayDatatype as ADT
File "arraydatatype.pyx", line 1, in init OpenGL_accelerate.arraydatatype (src/arraydatatype.c:9315)
File "wrapper.pyx", line 2, in init OpenGL_accelerate.wrapper (src/wrapper.c:10792)
ValueError: level must be >= 0
Any idea why it's acting up like this?
EDIT: managed to get pyopengl working for python3 with following command:
sudo pip-3.3 install PyOpenGL
So... problem solved I guess...
Answering my own question here, I managed to get PyOpenGL working with the command
sudo pip-3.3 install PyOpenGl