How to get RO package working in Python 3? I managed to get it to work in Python 2.7, but when I install it manually as python3 setup.py install and then do import RO.DS9 I get this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/DS9.py", line 160, in <module>
import RO.OS
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/OS/__init__.py", line 7, in <module>
from .OSUtil import *
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/OS/OSUtil.py", line 31, in <module>
import RO.SeqUtil
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/SeqUtil.py", line 33, in <module>
import UserString
ImportError: No module named 'UserString'
>>> exit()
In Python 3, UserString is part of the collections module.
As you can see on the RO page, this library does only support Python 2.6 and 2.7.
Related
I'm doing a project on opencv python which is based on downloaded source code from the internet. When I run the code, this error occurs
C:\Users\Udara\AppData\Local\Programs\Python\Python38-32\python.exe C:/Users/Udara/Desktop/7777/people-counting-opencv/people_counter.py
Traceback (most recent call last):
File "C:/Users/Udara/Desktop/7777/people-counting-opencv/people_counter.py", line 13, in <module>
from pyimagesearch.centroidtracker import CentroidTracker
File "C:\Users\Udara\Desktop\7777\people-counting-opencv\pyimagesearch\centroidtracker.py", line 5, in <module>
import ordereddict
File "C:\Users\Udara\AppData\Local\Programs\Python\Python38-32\lib\site-packages\ordereddict.py", line 23, in <module>
from UserDict import DictMixin
ModuleNotFoundError: No module named 'UserDict'
I'm trying to start with ANTLR . When I import module antlr it's working just fine , but if I try to import MyGrammarLexer and MyGrammarParser , it's shows that MyGrammarLexer and Parser aren't in lib. I Using PyCharm , I installed ANTLR with : pip3 install antlr4-python3-runtime my code is :
import sys
from antlr4 import *
import MyGrammarLexer
import MyGrammarParser
def main(argv):
input = FileStream(argv[1])
lexer = MyGrammarLexer(input)
stream = CommonTokenStream(lexer)
parser = MyGrammarParser(stream)
tree = parser.startRule()
if __name__ == '__main__':
main(sys.argv)
Maybe whom know why i can't import MyGrammarLexer and MyGrammarParser?
Please suggest!
Tackback:
/usr/bin/python3.6 /home/andrejka/PycharmProjects/Parser/parser.py
Traceback (most recent call last):
File "/home/andrejka/PycharmProjects/Parser/parser.py", line 2, in <module>
from antlr4 import *
File "/usr/lib/python3/dist-packages/antlr4/__init__.py", line 5, in <module>
from antlr4.BufferedTokenStream import TokenStream
File "/usr/lib/python3/dist-packages/antlr4/BufferedTokenStream.py", line 19, in <module>
from antlr4.error.Errors import IllegalStateException
File "/usr/lib/python3/dist-packages/antlr4/error/Errors.py", line 5, in <module>
from antlr4.atn.Transition import PredicateTransition
File "/usr/lib/python3/dist-packages/antlr4/atn/Transition.py", line 19, in <module>
from __builtin__ import unicode
ModuleNotFoundError: No module named '__builtin__'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "/home/andrejka/PycharmProjects/Parser/parser.py", line 2, in <module>
from antlr4 import *
File "/usr/lib/python3/dist-packages/antlr4/__init__.py", line 5, in <module>
from antlr4.BufferedTokenStream import TokenStream
File "/usr/lib/python3/dist-packages/antlr4/BufferedTokenStream.py", line 19, in <module>
from antlr4.error.Errors import IllegalStateException
File "/usr/lib/python3/dist-packages/antlr4/error/Errors.py", line 5, in <module>
from antlr4.atn.Transition import PredicateTransition
File "/usr/lib/python3/dist-packages/antlr4/atn/Transition.py", line 19, in <module>
from __builtin__ import unicode
ModuleNotFoundError: No module named '__builtin__'
I ran into this problem recently when getting the same error using the pddlpy python library. I was able to fix it by doing the following:
pip3 install antlr4-python3-runtime==4.9
The version 4.9 at the end is very important.
I found out that content of the package:
https://pypi.python.org/packages/0b/6b/30c5b84d203b62e1412d14622e3bae6273399d79d20f3a24c8145213f610/antlr4-python3-runtime-4.7.tar.gz#md5=190245a0fb4abf43568489a4b6e33aba
is different from the package installed by pip3.
I have replaced content of:
~/anaconda3/envs/py3/lib/python3.6/site-packages/antlr4
with content from the package I have downloaded and extracted manually:
~/Downloads/antlr4-python3-runtime-4.7/src/antlr4
It seems to be working now - in particular the following error:
ModuleNotFoundError: No module named '__builtin__'
does not occur.
After posting your traceback I can see the error is:
ModuleNotFoundError: No module named '__builtin__'
That means the package you try to import is using python2 syntax, but you're using python3.
You should use python2 if you need to run this package, but keep in mind that you probably want to search for a different one if this is a new project.
More about why it's not working here
EDIT
They released a package with python3 support, but it seems you installed/used something different. You should verify it.
Python 3.5 On Mac OS 10.12.2
When importing xlwings module i get a:
traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import xlwings
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/xlwings/__init__.py", line 24, in <module>
from . import _xlmac as xlplatform
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/xlwings/_xlmac.py", line 10, in <module>
import aem
ImportError: No module named 'aem'
I have appscript installed already.
Any idea what i am missing here please?
I installed Ubuntu 12.04 64 bit on a new system, and cannot install functools. I have installed this multiple times but do not remember getting this error, and cannot find any solution through Google. What do I need to do?
(myvenv)bobs#myvenv:~$ pip install functools
Downloading/unpacking functools
Downloading functools-0.5.tar.gz
Running setup.py egg_info for package functools
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/dist.py", line 10, in <module>
from setuptools.compat import numeric_types, basestring
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 71, in <module>
import socket
File "/usr/lib/python2.7/socket.py", line 49, in <module>
from functools import partial
File "functools.py", line 72, in <module>
globals()['c_%s' % x] = globals()[x] = getattr(_functools, x)
AttributeError: 'module' object has no attribute 'compose'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/extension.py", line 5, in <module>
from setuptools.dist import _get_unpatched
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/dist.py", line 10, in <module>
from setuptools.compat import numeric_types, basestring
File "/home/bobs/.virtualenvs/myvenv/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 71, in <module>
import socket
File "/usr/lib/python2.7/socket.py", line 49, in <module>
from functools import partial
File "functools.py", line 72, in <module>
globals()['c_%s' % x] = globals()[x] = getattr(_functools, x)
AttributeError: 'module' object has no attribute 'compose'
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/bobs/.virtualenvs/myvenv/build/functools
Storing complete log in /home/bobs/.pip/pip.log
Python2.7 comes with the functools module included.
You can install functools32 if you want to get the lru-cache decorator, which was introduced with Python3.2.
Edit: I actually checked this. I got the same error when I tried to pip-install functools with Python2.7. Simply do import functools and proceed as usual.
Make sure that it is functools32 in python version 2.x. In 3.x the tools come inbuilt.
Got a solution on windows.
Delete anything reference to functools in site-packages folder.
easy_install -U pip==7.1.2
I am using python 2.6 and trying to install django tagging package and i get this error below.I am installing few python 2.4 packages on a 64 bit machine which already has python2.6.
How to resolve this error
[root#tom django-tagging-0.3.1]# python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from distutils.command.install import INSTALL_SCHEMES
File "/usr/lib64/python2.6/distutils/command/install.py", line 21, in <module>
from site import USER_BASE
ImportError: cannot import name USER_BASE
EDIT 1
[root#tom django-tagging-0.3.1]# python2.6 setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from distutils.command.install import INSTALL_SCHEMES
File "/usr/lib64/python2.6/distutils/command/install.py", line 21, in <module>
from site import USER_BASE
ImportError: cannot import name USER_BASE
EDIT2
>>> from distutils.sysconfig import get_python_lib
>>> print(get_python_lib())
/usr/lib/python2.6/site-packages
EDIT3
>>> import site ; print site
<module 'site' from '/opt/mysite/site/__init__.pyc'>
You've called one of your Django apps "site". This is shadowing the site module in the stdlib. Rename it.