Python click project, "Django is not available on the PYTHONPATH " error - django

I am having a click project which don't use/need Django anywhere but while running prospector as part of static analysis throws this strange error
Command
prospector -I __init__.py --strictness veryhigh --max-line-length 120 src/
Error
Line: 1
pylint: django-not-available / Django is not available on the PYTHONPATH
There was no reference of django anywhere in the project/code . I am fairly new to python, Am i missing something obivious here ?
python-version : 3.7
pip list
apipkg 1.5
asn1crypto 1.2.0
astroid 2.3.2
atomicwrites 1.3.0
attrs 19.3.0
auger-python 0.1.35
bitmath 1.3.3.1
boto3 1.10.14
botocore 1.13.14
bravado 9.2.0
bravado-core 4.9.1
certifi 2019.9.11
cffi 1.13.2
chardet 3.0.4
click 6.7
colorama 0.4.1
coloredlogs 10.0
coverage 4.5.4
cryptography 2.3.1
deb-pkg-tools 4.5
docutils 0.15.2
dodgy 0.1.9
entrypoints 0.3
execnet 1.7.1
executor 21.3
fasteners 0.15
filelock 3.0.12
flake8 3.7.9
flake8-polyfill 1.0.2
funcsigs 1.0.2
future 0.18.2
humanfriendly 4.18
hvac 0.7.1
idna 2.5
importlib-metadata 0.23
isort 4.3.21
jmespath 0.9.4
jsonpointer 2.0
jsonschema 3.1.1
lazy-object-proxy 1.4.3
mando 0.6.4
mccabe 0.6.1
mock 3.0.5
monotonic 1.5
more-itertools 7.2.0
murl 0.5.1
packaging 19.2
pep8 1.7.1
pep8-naming 0.4.1
pip 19.3.1
pluggy 0.13.0
property-manager 2.3.1
prospector 1.1.7
py 1.8.0
pycodestyle 2.5.0
pycparser 2.19
pydocstyle 4.0.1
pyflakes 2.1.1
pylint 2.4.3
pylint-celery 0.3
pylint-django 2.0.10
pylint-flask 0.6
pylint-plugin-utils 0.6
pyparsing 2.4.4
pyrsistent 0.15.5
pytest 5.2.2
pytest-cache 1.0
pytest-cov 2.8.1
pytest-pep8 1.0.6
python-dateutil 2.6.1
python-debian 0.1.33
python-memcached 1.59
pytz 2019.3
PyYAML 5.1.2
radon 4.0.0
raven 6.9.0
requests 2.19.1
requirements-detector 0.6
rfc3987 1.3.8
customcli 0.1.dev27+g2b07461.d20191114
s3transfer 0.2.1
setoptconf 0.2.0
setuptools 41.6.0
simplejson 3.16.0
six 1.12.0
snowballstemmer 2.0.0
strict-rfc3339 0.7
swagger-spec-validator 2.4.3
toml 0.10.0
tox 3.14.0
tryagain 1.0
typed-ast 1.4.0
urllib3 1.23
verboselogs 1.7
virtualenv 16.7.7
wcwidth 0.1.7
webcolors 1.10
wheel 0.33.6
wrapt 1.11.2
zipp 0.6.0

As I said in my comments I think there is a bug with prospector and requirement-detector.
I was able to reproduce the problem by just installing prospector 1.1.7 in an empty virtualenv:
$ pip freeze
astroid==2.2.5
dodgy==0.1.9
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
pep8-naming==0.4.1
prospector==1.1.7
pycodestyle==2.3.1
pydocstyle==4.0.1
pyflakes==1.6.0
pylint==2.3.1
pylint-celery==0.3
pylint-django==2.0.10
pylint-flask==0.6
pylint-plugin-utils==0.6
PyYAML==5.1.2
requirements-detector==0.6
setoptconf==0.2.0
six==1.13.0
snowballstemmer==2.0.0
typed-ast==1.4.0
wrapt==1.11.2
Then creating a dummy code:
$ cat src/__init__.py
print('something')
When running prospector I got the same error:
$ prospector src/
/home/sma/.pyenv/versions/3.7.3/envs/58918408_so/lib/python3.7/site-packages/pycodestyle.py:113: FutureWarning: Possible nested set at position 1
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
Messages
========
src/__init__.py
Line: 1
pylint: django-not-available / Django is not available on the PYTHONPATH
Check Information
=================
Started: 2019-11-18 17:57:27.136877
Finished: 2019-11-18 17:57:27.301151
Time Taken: 0.16 seconds
Formatter: grouped
Profiles: default, no_doc_warnings, no_test_warnings, strictness_medium, strictness_high, strictness_veryhigh, no_member_warnings
Strictness: None
Libraries Used: django, flask, celery
Tools Run: dodgy, mccabe, pep8, profile-validator, pyflakes, pylint
Messages Found: 1
Since prospector issue 245 and pylint django PR 137 Django became an extra dependency of pylint-django.
But running it without django installed still return a message:
$ pylint --load-plugins pylint_django src
************* Module src
src/__init__.py:1:0: C0111: Missing module docstring (missing-docstring)
src/__init__.py:1:0: F5101: Django is not available on the PYTHONPATH (django-not-available)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
My guess is prospector catch that message and return it when ran directly i.e with dependency automatic detection.
This seems like an bug/integration problem between the two libraries for me, but a confirmation from a contributor/maintainer from one the project is required.
Otherwise #Thaveedu a workaround is to disable the dependency automatic detection since in your case you probably don't care about django, flask or celery anyway:
$ prospector --no-autodetect src/
/home/sma/.pyenv/versions/3.7.3/envs/58918408_so/lib/python3.7/site-packages/pycodestyle.py:113: FutureWarning: Possible nested set at position 1
EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
Check Information
=================
Started: 2019-11-18 18:07:30.662236
Finished: 2019-11-18 18:07:30.804708
Time Taken: 0.14 seconds
Formatter: grouped
Profiles: default, no_doc_warnings, no_test_warnings, strictness_medium, strictness_high, strictness_veryhigh, no_member_warnings
Strictness: None
Libraries Used:
Tools Run: dodgy, mccabe, pep8, profile-validator, pyflakes, pylint
Messages Found: 0

After some investigation, Propector supports Django, Celery and Flask, which means it automatically installs the Pylint plugins needed for it to support these frameworks.
Is it possible you have specified to use pylint-django? In order for pylint-django to inspect Django code it requires Django to be installed, prospector docs states it doesn't normally automatically detect your project's dependencies, but it states you can turn them off using:
prospector --no-autodetect
Let me know if this helps.

Related

Dune version not supported

I am trying to install google-drive-ocamlfuse from source, but the prereuiqisites got me a little confused. I am experiencing this error:
[bf#localhost google-drive-ocamlfuse]$ dune build #install
File "/home/bf/.opam/default/lib/gapi-ocaml/dune-package", line 1, characters 11-15:
1 | (lang dune 1.11)
^^^^
Error: Version 1.11 of dune is not supported.
Supported versions:
- 0.0
- 1.0 to 1.7
I have dune version 1.7 installed:
[bf#localhost google-drive-ocamlfuse]$ dune --version
%%VERSION%%
[bf#localhost google-drive-ocamlfuse]$ sudo dnf install dune
[sudo] password for bf:
Last metadata expiration check: 0:48:24 ago on Wed 21 Aug 2019 15:57:42 CEST.
Package ocaml-dune-1.7.3-1.fc29.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
But apparently, gapi-ocaml needs dune 1.11, or am I completely mistaken? I have no experience with OCaml or dune or all the other tools...
How can I get this installed?
Don't use your distribution's version of dune. Instead, get it via opam:
dnf remove dune
opam install dune

nltk module installation in pip through cmd

When I tried to run this command:
c:\python27\scripts\pip install nltk-3.2.1-py2.py3-none-any
I am getting the error:
no matching distribution found
Although i have installed nltk from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#nltk
Kindly help.
I am working on Windows 8 64-bit Version
Installing new modules can be a nightmare if you are new to Python.First delete any old versions of NLTK if already installed. Open cmd navigate to C:\Users\user\AppData\Local\Programs\Python\Python35-32\Scripts, the default directory, using the command cd path_name_comes_here. Otherwise goto the path where you have installed python and goto the Scripts subfolder and use this path here onwards. Now the most preferred way is to use pip install module_you_want_to_install for anything in python. Pip automatically fetches everything it needs to install said module.
Simply use pip install nltk.
Another method is to use easy_install requirement_or_URL.
Some rare occasions its best to download the wheel from http://www.lfd.uci.edu/~gohlke/pythonlibs and from there you can simply use pip install downloaded_wheel_name again. But make sure to copy the name of the wheel EXACTLY.
Post installation make sure that your package is accessible from C:\Users\user\AppData\Local\Programs\Python\Python35-32\Lib\site-packages or a similar path depending on where you installed python.
Try Anaconda - Instead . Always works
C:\Users\sanan>conda install -c anaconda nltk
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment C:\Users\sanan\Miniconda3:
The following NEW packages will be INSTALLED:
nltk: 3.2.4-py36_0 anaconda
The following packages will be UPDATED:
conda: 4.3.23-py36_0 --> 4.3.25-py36_0 anaconda
The following packages will be SUPERSEDED by a higher-priority channel:
conda-env: 2.6.0-0 --> 2.6.0-0 anaconda
Proceed ([y]/n)? y
conda-env-2.6. 100% |###############################| Time: 0:00:00 22.84 kB/s
nltk-3.2.4-py3 100% |###############################| Time: 0:00:02 774.24 kB/s
conda-4.3.25-p 100% |###############################| Time: 0:00:00 578.90 kB/s
After installation is complete .
import nltk
print(nltk.__version__)
C:\Public\Code\textnorm>python attempt1.py
3.2.4

Pyinstaller freezes an invalid binary when includes ZMQ

I'm trying to freeze a binary with PyInstaller that includes ZMQ code. When testing the application everything works fine with Python interpreter, but final binary does not work at all.
Note: A different code is used here to illustrate and simplify the error:
try:
import zmq
zmq.Context()
except Exception, e:
print str(e)
print 'end'
Python version is 2.7.6, Operating System is CentOS 6.7 and I'm working with a virtual environment which includes the following packages:
(Compiler)[user#machine test]$ pip list
backports.ssl-match-hostname (3.4.0.2)
certifi (2015.9.6.2)
cffi (1.2.1)
cryptography (1.0.1)
Cython (0.23.1)
distribute (0.7.3)
enum34 (1.0.4)
futures (3.0.3)
idna (2.0)
ipaddress (1.0.14)
Jinja2 (2.8)
M2Crypto (0.22.3)
MarkupSafe (0.23)
msgpack-python (0.4.6)
npyscreen (4.10.0)
pip (7.1.2)
psutil (3.2.1)
pyasn1 (0.1.8)
pycparser (2.14)
pycrypto (2.6.1)
PyInstaller (2.1)
pyroute2 (0.3.14)
python-iptables (0.9.0)
pytz (2015.4)
PyYAML (3.11)
pyzmq (14.7.0)
requests (2.7.0)
salt (2015.5.5)
setuptools (18.0.1)
six (1.9.0)
tornado (4.2.1)
tzlocal (1.2)
wheel (0.24.0)
And this other rpm package has been installed through YUM tool:
[root#machine test]# rpm -qa | grep -i zmq
python-zmq-14.3.1-1.el6.x86_64
Case ONE: Works with Python Interpreter.
(Compiler)[user#machine test]$ python test.py
end
Case TWO: Does NOT work after PyInstaller.
(Compiler)[user#machine test]$ pyinstaller --onefile test.py
...
12135 INFO: building EXE from out00-EXE.toc
12136 INFO: Appending archive to EXE /test/dist/tes
(Compiler)[user#machine test]$ /test/dist/test
/tmp/_MEIl3jKVa/zmq/libzmq.so: undefined symbol: crypto_secretbox_open
end
What I'm missing? Thanks in advance!
Problem seems to be fixed by downgrading pyzmq version from 14.X to 13.X (eg: 13.1.0 has been tested successfully).
I think pyzmq includes pyNacl (libsodium) libraries on 14.X and onwards. However, I have also tried to freeze with Pyinstaller after installing pyNacl (0.3.0) in my virtual environment and I got the same error.
Does anyone knows how to do this with latest version of pyzmq?

Problems installing NoseXUnit

I tried to install NoseXUnit using pip. Trying to run nosetests with it ends with the following error message:
# nosetests --with-nosexunit
/usr/lib/python2.7/site-packages/nose-1.3.0-py2.7.egg/nose/plugins/manager.py:395: RuntimeWarning: Unable to load plugin nosexunit = nosexunit.plugin:NoseXUnit: (coverage 3.7.1 (/usr/lib/python2.7/site-packages), Requirement.parse('coverage==2.85'))
RuntimeWarning)
Usage: nosetests [options]
nosetests: error: no such option: --with-nosexunit
So it seems like there's a problem with "coverage" version - I have version 3.7.1 and for some reason it requires 2.85:
# nosetests --help | grep -i nosex
/usr/lib/python2.7/site-packages/nose-1.3.0-py2.7.egg/nose/plugins/manager.py:395: RuntimeWarning: Unable to load plugin nosexunit = nosexunit.plugin:NoseXUnit: (coverage 3.7.1 (/usr/lib/python2.7/site-packages), Requirement.parse('coverage==2.85'))
RuntimeWarning)
Is that issue? Also, pip install coverage==2.85 doesn't work.
What can I do in order to fix nose to work with NoseXUnit?
Any alternative for xml based reports framework is also welcomed (jenkins purposes).
nose supports xunit output with built-in plugin, just try --with-xunit

pip can't find latest versions of a pypi project

I'm trying to install http://pypi.python.org/pypi/django-crowdsourcing/1.1.21 using pip. I'm getting
$ pip install django-crowdsourcing==1.1.21
Downloading/unpacking django-crowdsourcing==1.1.21
Could not find a version that satisfies the requirement django-crowdsourcing==1.1.21 (from versions: )
No distributions matching the version for django-crowdsourcing==1.1.21
If I try an upgrade, it only finds version 1.1.19.
$ pip install -v --upgrade django-crowdsourcing
Downloading/unpacking django-crowdsourcing
Using version 1.1.19 (newest of versions: 1.1.19, 1.1.18, 1.1.17, 1.1.16, 1.1.15, 1.1.14, 1.1.13, 1.1.12, 1.1.11, 1.1.10, 1.1.9, 1.1.8, 1.1.7, 1.1.6)
Downloading django-crowdsourcing-1.1.19.tar.gz (651Kb): 651Kb downloaded
...
Successfully installed django-crowdsourcing
It looks like django-crowdsourcing version 1.1.21 has some good tags
$ hg tags
tip 289:8796aae85e34
1.1.21 288:2f39596495a7
1.1.20 281:fe00699aa3ff
1.1.19 278:17392ea8ea54
and the correct version number in setup.py
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
import os
readme_file = os.path.join(os.path.dirname(__file__),
'README')
long_description = open(readme_file).read()
classifiers = [
'Development Status :: 4 - Beta',
'Framework :: Django',
'License :: OSI Approved :: MIT License']
setup(name='django-crowdsourcing',
version='1.1.21',
classifiers=classifiers,
description='Django app for collecting and displaying surveys.',
long_description=long_description,
author='Jacob Smullyan, Dave Smith',
author_email='jsmullyan#gmail.com',
url='http://code.google.com/p/django-crowdsourcing/',
packages=['crowdsourcing', 'crowdsourcing.templatetags'],
license='MIT',
)
PyPi clearly knows about version 1.1.21 since that's what comes up when you go to http://pypi.python.org/pypi/django-crowdsourcing/ Why does pip think version 1.1.19 is the latest version?
Edit
Sheepishly, I forgot to point out I'm the maintainer. #Matthew Schinckel is right. Here are the two commands I needed, which I found out from a tutorial I didn't see before: http://wiki.python.org/moin/Distutils/Tutorial
$ python setup.py register
$ python setup.py sdist upload
There is no packaged file at version 1.1.21. There is one at 1.1.19. Tags in hg mean nothing to pip: it will only download a packaged up file.
Perhaps contact the maintainer, and point out there is no file release with the two most recent versions on pypi.