Running Pylint on Windows -> ImportError: cannot import from builtins - python

Maybe someone has a clue about this one. Google, the Logilab.org archives and every other source I tried to determine a solution have turned up empty.
I was trying to get Pylint 2.4 running with PyDev in Eclipse (with Python 2.6) on Windows, but right now I'd be happy simply running pylin at all. I used easy_install to install pylint and it's dependancies. That seemed to work fine. However if I try to run c:\python26\Scripts\pylint.bat , I get the following:
Traceback (most recent call last):
File "C:\Python26\Scripts\pylint", line 5, in <module>
pkg_resources.run_script('pylint==0.24.0', 'pylint')
File "c:\Python26\lib\site-packages\pkg_resources.py", line 489, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "c:\Python26\lib\site-packages\pkg_resources.py", line 1207, in run_script
execfile(script_filename, namespace, namespace)
File "c:\python26\lib\site-packages\pylint-0.24.0-py2.6.egg\EGGINFO\scripts\pylint", line 3, in <module>
from pylint import lint
File "c:\Python26\lib\site-packages\pylint-0.24.0-py2.6.egg\pylint\lint.py", line 31, in <module>
from pylint.checkers import utils
File "c:\Python26\lib\site-packages\pylint-0.24.0py2.6.egg\pylint\checkers\__init__.py", line 44, in <module>
from logilab.astng.utils import ASTWalker
File "c:\Python26\lib\site-packages\logilab_astng-0.22.0py2.6.egg\logilab\astng\__init__.py", line 58, in <module>
from logilab.astng.nodes import *
File "c:\Python26\lib\site-packages\logilab_astng-0.22.0-py2.6.egg\logilab\astng\nodes.py", line 54, in <module>
from logilab.astng.node_classes import Arguments, AssAttr, Assert, Assign, \
File "c:\Python26\lib\site-packages\logilab_astng-0.22.0-py2.6.egg\logilab\astng\node_classes.py", line 27, in <module>
from logilab.astng.bases import (NodeNG, Statement, Instance, InferenceContext,
File "c:\Python26\lib\site-packages\logilab_astng-0.22.0-py2.6.egg\logilab\astng\bases.py", line 28, in <module>
from logilab.common.compat import builtins
ImportError: cannot import name builtins
I mucked around and looked into based.py, but I have no clue what the problem is. My shell path includes C:\python26;c:\Python26\Scripts.
Does this have something to do with lib2to3? Or Python 2.6 compatibility?
Note that I installed pylint using "easy_install pylint", and logilab-common is at the latest 0.56.2.
Thanks!

For me, there is a logilab.common.compat module buried inside the egg "logilab.pylintinstaller-0.15.2-py2.6.egg" in my site-packages folder. Having the logilab_common egg installed, removing the pylintinstaller egg got pylint working in eclipse. I found this out via IPython like so:
In [37]: import logilab.common.compat
In [38]: from logilab.common.compat import builtins
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
C:\Users\Rio\Documents\mcedit\pymclevel\<ipython console> in <module>()
ImportError: cannot import name builtins
In [41]: logilab.common.compat.__file__
Out[41]: 'c:\\python26\\lib\\site-packages\\logilab.pylintinstaller-0.15.2-py2.6.egg\\logilab\\common\\compat.pyc'

Probably you don't have the logilab.common package or the installed version is an old one.
try:
easy_install-2.6 --upgrade logilab-common

Related

Cannot import tensorflow in python3 and ImportError: This package should not be accessible on Python 3

I am trying to use tensorflow for research in my macbook. I use pip3 to install tensorflow in the system (not in virtual environment).
At first, I just want to verify tensorflow can be correctly imported via python3 in terminal. However, sometimes, I got the following problem when importing.
>>>import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cyan/Library/Python/3.5/lib/python/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Users/cyan/Library/Python/3.5/lib/python/site-packages/tensorflow/python/__init__.py", line 47, in <module>
import numpy as np
File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/Library/Python/2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Library/Python/2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/Library/Python/2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/Library/Python/2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: dlopen(/Library/Python/2.7/site-packages/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
Referenced from: /Library/Python/2.7/site-packages/numpy/core/multiarray.so
Expected in: flat namespace in /Library/Python/2.7/site-packages/numpy/core/multiarray.so
This error could only be solved if I ran the following code firstly before python3 execution
unset PYTHONPATH
If I didn't unset PYTHONPATH, I also found errors when checking the version of pip3 using
pip3 --version
The errors are shown as follows.
>> pip3 --version
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 6, in <module>
from pip._internal import main
File "/Library/Python/2.7/site-packages/pip/_internal/__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
File "/Library/Python/2.7/site-packages/http/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
I thought it was so inconvenient to unset PYTHONPATH every time, so is there any solutions for this problem? I also want to import tensorflow in other text editor, such as Sublime and Pycharm, so I was really not sure what to do next.
I tried the same scenario. It is working fine for me. In the first error it seems your python installation is messed up. If you are using python3 in terminal, it should not refer to 2.7 libraries.
Also I dont think you require unset PYTHONPATH everytime. First thing is you dont need to setup PYTHONPATH. It seems the installation got issue.
You using homebrew in mac to install packages. If not I will say use homebrew and it will work as charm. As it adds dependency properly.
Thanks,
Ashish

"No module named zlib" error anytime I use pip

I'm using terminal on mac, and anytime I attempt to use pip, I get the following error message telling me that it cannot find a module named zlib:
$ pip --version
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 27, in <module>
from . import urllib3
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 42, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python3.6/site-packages/pip/__init__.py", line 21, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/__init__.py", line 62, in <module>
from .packages.urllib3.exceptions import DependencyWarning
File "/usr/local/lib/python3.6/site-packages/pip/_vendor/requests/packages/__init__.py", line 29, in <module>
import urllib3
File "/usr/local/lib/python3.6/site-packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 36, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python3.6/site-packages/urllib3/response.py", line 3, in <module>
import zlib
ModuleNotFoundError: No module named 'zlib'
I've read several SO posts with the same error message, and have tried their solutions, including attempting to install zlib using homebrew, which fails, and updating my Xcode developer tools. I also installed pip earlier using python get-pip.py, and it said it installed successfully.
The reason I need pip is to install a package for use on python 2.7, but doing $ pip install "package-name" produces the same error as above. I have both Python 2 and 3 installed on my machine, if that helps. I'm kind of new to pip and using the command line in general, and I'm super confused; if anyone could help me out I'd really appreciate it.
This is the OP. I was able to fix the issue, and wanted to post my solution here in case it would help others.
Essentially I believe it occurred because Python2 is default on my machine, but pip is by default pointing to resources pertaining to Python3, or something like that. Doing pip2 --version instead provided the expected response.

pip commands return a TypeError

I needed to install hashlib for one of my projects, and used easy_install hashlib (as was stated by this Stack Exchange post) to do so. However, right after I installed this package, I haven't been able to use pip at all. Whenever I type a command with pip (like pip install), I get the following error message:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 37, in <module>
import email.parser
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/feedparser.py", line 27, in <module>
from email import message
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py", line 16, in <module>
import email.charset
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/charset.py", line 13, in <module>
import email.base64mime
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/base64mime.py", line 40, in <module>
from email.utils import fix_eols
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py", line 27, in <module>
import random
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 49, in <module>
import hashlib as _hashlib
File "build/bdist.macosx-10.13-intel/egg/hashlib.py", line 115, in <module>
"""
TypeError: 'frozenset' object is not callable
This also now occurs when I'm using easy_install- same error. I'm also not able to uninstall pip and reinstall- any command with pip results in the error above. Even executing
pip --version yields the same error. I know it's something to do with the hashlib package, but I'm not sure how to delete it and reinstall without messing up my entire Python configurations. My hypothesis is that the version of hashlib I installed is either too old or too new for my Python 2.7, and doesn't play well with it.
Does anyone know what exactly is going on behind the scenes here in this stack trace, and how I can fix pip?
Is the best thing to do to literally go in and delete hashlib.py from my lib/python2.7 folder?
So, this doesn't solve the issue with hashlib, but it does get you a working pip again: literally download and reinstall Python 2.7 all over again from the source. If anyone comes up with a better, more elegant solution for fixing pip, I am all for it.
However, at least I can use pip again...

Trouble importing numba

Ok, I'm using python 3.3. I have numpy, llvm, llvmpy, llpyhton, llvm_array, llvm_cbuilder and llvmath installed. I have also installed numba.
However, when trying to import via import numba, the following error appears. I have no idea of what could be missing:
Traceback (most recent call last):
File "/home/pablo/workspace/Pruebas/src/Prueba2/__init__.py", line 1, in <module>
import numba
File "/usr/local/lib/python3.3/dist-packages/numba/__init__.py", line 18, in <module>
from numba import utils, typesystem
File "/usr/local/lib/python3.3/dist-packages/numba/utils.py", line 102, in <module>
context = get_minivect_context()
File "/usr/local/lib/python3.3/dist-packages/numba/utils.py", line 100, in get_minivect_context
return NumbaContext()
File "/usr/local/lib/python3.3/dist-packages/numba/minivect/miniast.py", line 138, in __init__
import llvm.core as llvm_py_not_available # llvm-py not available
File "/usr/local/lib/python3.3/dist-packages/llvm/__init__.py", line 6, in <module>
from llvmpy import extra
File "/usr/local/lib/python3.3/dist-packages/llvmpy/extra.py", line 6, in <module>
from llvmpy import _api
ImportError: libLLVM-3.2.so: cannot open shared object file: No such file or directory
Any ideas?
Ok, I found out what was wrong.
I added the anaconda folders to the deafault python3 interpreter, instead of installing numba directly in the packages folder.

ImportError: Module use of python26.dll conflicts with this version of Python

I use Python 3.2.3
Tonight I tried to install requests from http://docs.python-requests.org/en/latest/ by pip and easy_install, but it doesn't work. I have error when trying to import it. So I decided to use standard library urllib.request and see this error again
That is the traceback:
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\__init__.py", line 52, in <module>
from . import utils
File "E:\Python32\lib\site-packages\requests-1.2.0-py3.2.egg\requests\utils.py", line 12, in <module>
import cgi
File "E:\Python32\lib\cgi.py", line 38, in <module>
from email.parser import FeedParser
File "E:\Python32\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser
File "E:\Python32\lib\email\feedparser.py", line 27, in <module>
from email import message
File "E:\Python32\lib\email\message.py", line 17, in <module>
from email import utils
File "E:\Python32\lib\email\utils.py", line 28, in <module>
import socket
File "E:\Python32\lib\socket.py", line 46, in <module>
import _socket
ImportError: Module use of python26.dll conflicts with this version of Python.
So how can I fix this?
UPD: Solved. It was bug in SublimeREPL, reinstalled that package.
I had a similar problem when I was using PythonXY. The Spyder was not loading and it turns out another software OpenCAD had installed Python2.6 version and that was not letting my Python27.dll to not work. After uninstalling OpenCAD, I was able to run the software.
I was able to troubleshoot by first searching for python26.dll and found that this file was located in the OpenCAD folder location and that made me realize that this software was causing the issue.

Categories

Resources