Django Lint throwing error - django

I installed Python Lint for static analysis of Python code
pylint --version:
No config file found, using default configuration
pylint 1.4.1,
astroid 1.3.4, common 0.63.2
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2]
I am currently working on a django project, for which I installed python-django-lint package. But when I invoke the django-lint it throws an error:
Traceback (most recent call last):
File "/usr/bin/django-lint", line 25, in <module>
sys.exit(script.main())
File "/usr/lib/pymodules/python2.7/DjangoLint/script.py", line 119, in main
AstCheckers.register(linter)
File "/usr/lib/pymodules/python2.7/DjangoLint/AstCheckers/__init__.py", line 22, in register
from size import SizeChecker
File "/usr/lib/pymodules/python2.7/DjangoLint/AstCheckers/size.py", line 19, in <module>
from pylint.interfaces import IASTNGChecker
ImportError: cannot import name IASTNGChecker
I am using Python 3.4 and Django 1.6.

Install the python3-pip package, remove the python-django-lint package and call then sudo pip3 install pylint-django.
To invoke it, call pylint --load-plugins pylint_django...

Related

how to install numba and link to llvm & llvmlite to import it in Python27

When I am trying to run python file .py that uses numba it gives me the below error
Traceback (most recent call last):
File "C:\Myfile.py", line 16, in <module>
import myfile2 as m
File "C:\myfile2.py", line 8, in <module>
import numba
File "C:\Python27\lib\site-packages\numba\__init__.py", line 9, in <module>
from . import config, errors, runtests, types
File "C:\Python27\lib\site-packages\numba\config.py", line 11, in <module>
import llvmlite.binding as ll
File "C:\Python27\lib\site-packages\llvmlite\binding\__init__.py", line 6, in <module>
from .dylib import *
File "C:\Python27\lib\site-packages\llvmlite\binding\dylib.py", line 4, in <module>
from . import ffi
File "C:\Python27\lib\site-packages\llvmlite\binding\ffi.py", line 50, in <module>
raise e
WindowsError: [Error 126] The specified module could not be found
I've tried to isntall numba from command propmt as below :
pip install numba
but it gives me a message that it already exists before
Requirements already satisfied...........etc
so could anyone help me to fix this error ? also How to install numba and link it with llvm and llvmlite ?
I've uninstall the python and re-install it again
and install the below packages in order
pip install scikit_learn
pip install numby+mkl
pip install scipy
pip install numba
pip install matplotlib
also I've installed mini conda and it is working fine as well

ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

Possible duplicate of this question.
I have a gpu account to whom I connect through putty (ssh login). I have created a virtualenv there and I am installing tenorflow through pip for gpu. Everything works fine, when I run command
$ pip list
following list is being shown:
backports.weakref (1.0rc1)
bleach (1.5.0)
funcsigs (1.0.2)
html5lib (0.9999999)
Markdown (2.6.8)
mock (2.0.0)
numpy (1.13.1)
olefile (0.44)
pbr (3.1.1)
Pillow (4.2.1)
pip (9.0.1)
protobuf (3.3.0)
setuptools (36.0.1)
six (1.10.0)
tensorflow-gpu (1.2.1)
Werkzeug (0.12.2)
wheel (0.29.0)
But when I run:
$ python
>>> import tensorflow
It shows the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in
<module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/nauman/junaid/final/test/lib/python2.7/site-
packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in
swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname,
description)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such
file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I have also set my environment variables like this:
export CUDA_HOME=/opt/cuda
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64"
Moreover, I found that libcusolver.so.8.0 is not there, while libcusolver.so.7.5
is there in cuda/lib64/.
Somehow tensorflow is finding wrong file or I ain't know nothing.
Any help would be appreciated as I am new to all this stuff.
Python version: 2.7
OS: Linux
This may be connected to the incorrect linking of your libraries.
Simply run sudo ldconfig /usr/local/cuda/lib64. It solved for me.
If you need to know more: ldconfig man page.
I solved the issue. Actually I have cuda 7.5 installed and I was installing latest tensorflow version which probably support cuda 8.0.
So I downgraded.
pip install --upgrade \ https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.10.0-cp27-none-linux_x86_64.whl
If you installed tensorflow-gpu by using pip with prebuilt .whl, the cuda version were fixed. As far as I know, starting 0.11.0rc1, all the prebuilt packages are now built for cuda 8. So there are two ways to solve the problem:
install cuda 8 for the prebuilt packages tensorflow-gpu >= 0.11.orc1
keep cuda 7.5 stay, then build tensorflow-gpu from source code
If you are using cuda-9.0 try sudo apt install nvidia-cuda-dev (if you are using an Ubuntu distribution)

trouble importing skllearn

Hi i have installed the Scikit-learn but i keep getting error msgs when i try to import the sklearn module. it shows the following msg. anyone knows what's going on?
import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sklearn/__init__.py", line 31, in <module>
from . import __check_build
File "sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: No module named _check_build
___________________________________________________________________________
Contents of sklearn/__check_build:
__init__.py __init__.pyc _check_build.c
_check_build.pyx setup.py setup.pyc
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
As you can see in your errors: ImportError: No module named _check_build in that directory it has .c file and it never compiled.
If you check this link you will see many parts of scikit-learn has been written in C.
So for installing this kind of packages , you need to install python-dev package in your system.
python-dev package will install many C headers like python.h.
So install python-dev package in your system and then remove and install scikit-learn package again.

python3.2 + virtualenv - env create failed

I've got a py2.7 project which I want to test under py3.2. For this purpose, I want to use virtualenv. I wanted to create an environment that would run 3.2 version internally:
virtualenv 3.2 -p /usr/bin/python3.2
but it failed. My default python version is 2.7 (ubuntu default settings). Here is virtualenv --version 1.10. The error output is:
Running virtualenv with interpreter /usr/bin/python3.2
New python executable in 3.2/bin/python3.2
Also creating executable in 3.2/bin/python
Installing Setuptools...................................................................................................................................................................................................................................done.
Installing Pip..............
Complete output from command /home/tomasz/Develop...on/3.2/bin/python3.2 setup.py install --single-version-externally-managed --record record:
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from setuptools import setup, find_packages
File "/usr/lib/python2.7/dist-packages/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/usr/lib/python2.7/dist-packages/setuptools/extension.py", line 2, in <module>
from setuptools.dist import _get_unpatched
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 103
except ValueError, e:
^
SyntaxError: invalid syntax
----------------------------------------
...Installing Pip...done.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 2308, in <module>
main()
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 821, in main
symlink=options.symlink)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 963, in create_environment
install_sdist('Pip', 'pip-*.tar.gz', py_executable, search_dirs)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 932, in install_sdist
filter_stdout=filter_install_output)
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 899, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/tomasz/Develop...on/3.2/bin/python3.2 setup.py install --single-version-externally-managed --record record failed with error code 1
I don't know what the hell is this syntax error - where does it come from... I know there was a change in try...catch statement syntax between 2.x and 3.x, but should virtualenv throw syntax errors?
I'd be grateful if someone pointed me out if there's something I'm doing wrong or if there is an installation problem on my machine.
To create a Python 3.2 virtual environment you should use the virtualenv you installed for Python 3.2. In your case that would be:
/usr/bin/virtualenv-3.2
You'll have to use a Python 3 version of virtualenv; the version you are using is installing Python 2 tools into a Python 3 virtual environment and these are not compatible.
virtualenv --python=/usr/bin/python3.2 --no-site-packages ENV

Problems running Cython

I'm trying to run cython with Python2.7 installed using OSX running Mountain Lion but I get the following errors:
Traceback (most recent call last):
File "/usr/local/bin/cython", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: Cython==0.17
How can I fix this?
Thanks!
Probably what happened is that you installed cython with one version of python and are trying to run it with another. Rather than doing the standard
python setup.py build
sudo python setup.py install
Try just switching to root and both building and installing using an explicit version of python:
sudo su
/usr/bin/python setup.py build
/usr/bin/python setup.py install
(Note that this all assumes that you're installing from a source tarball).