Using Python2 and scrapy ImportError: cannot import name suppress - python-2.7

Hi am trying to run a scraper on ubuntu/windows machine .
I have installed scrapy version- Scrapy 1.8.0 on using python2.
I am able create a project, but when I run a scraper this error in shown.
Traceback (most recent call last):
File "/home/ubuntu/.local/bin/scrapy", line 8, in <module>
sys.exit(execute())
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/cmdline.py", line 146, in execute
_run_print_help(parser, _run_command, cmd, args, opts)
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/cmdline.py", line 100, in _run_print_help
func(*a, **kw)
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/cmdline.py", line 154, in _run_command
cmd.run(args, opts)
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/commands/shell.py", line 68, in run
crawler.engine = crawler._create_engine()
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/crawler.py", line 111, in _create_engine
return ExecutionEngine(self, lambda _: self.stop())
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/core/engine.py", line 67, in __init__
self.scheduler_cls = load_object(self.settings['SCHEDULER'])
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/utils/misc.py", line 46, in load_object
mod = import_module(module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/ubuntu/.local/lib/python2.7/site-packages/scrapy/core/scheduler.py", line 7, in <module>
from queuelib import PriorityQueue
File "/home/ubuntu/.local/lib/python2.7/site-packages/queuelib/__init__.py", line 1, in <module>
from queuelib.queue import FifoDiskQueue, LifoDiskQueue
File "/home/ubuntu/.local/lib/python2.7/site-packages/queuelib/queue.py", line 7, in <module>
from contextlib import suppress
ImportError: cannot import name suppress
can anyone help to solve this issue?

The contextlib.suppress function supports from Python 3.4 but you are using Python 2.7. To solve this problem, upgrade your python version.

If this is useful for someone else, the solution for me (also using python 2.7) was:
pip uninstall attrs
pip uninstall queuelib
pip install queuelib==1.5.0
pip install attrs

Related

Trying to install Django reversion

I'm trying to setup a Django project but Im getting this:
python2.7 manage.py migrate
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 94, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named reversion
So I'm trying to instal reversion, but I'm getting this error message when trying to installenter code here it:
$sudo pip install django-reversion
Downloading/unpacking django-reversion
Downloading django-reversion-3.0.7.tar.gz (67kB): 67kB downloaded
Running setup.py (path:/tmp/pip_build_root/django-reversion/setup.py) egg_info for package django-reversion
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/django-reversion/setup.py", line 28, in <module>
long_description=read('README.rst'),
File "/tmp/pip_build_root/django-reversion/setup.py", line 19, in read
with open(filepath, "r", encoding="utf-8") as f:
TypeError: 'encoding' is an invalid keyword argument for this function
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/django-reversion/setup.py", line 28, in <module>
long_description=read('README.rst'),
File "/tmp/pip_build_root/django-reversion/setup.py", line 19, in read
with open(filepath, "r", encoding="utf-8") as f:
TypeError: 'encoding' is an invalid keyword argument for this function
----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/django-reversion
Storing debug log for failure in /home/tirengarfio/.pip/pip.log
I'm on Ubuntu 16.04 and python 2.7.
That Python3-only open() was added with version 3.0.6. Try earlier versions, 3.0.5 or 3.0.4:
pip install django-reversion==3.0.5
or
pip install django-reversion==3.0.4
Django 3 supports python versions 3.6 and above.
Here is the official Django 3.0 release notes

Not able to resolve AttributeError: 'module' object has no attribute 'SSL_ST_INIT' while installing django dependencies

Using MacOS Sierra 10.12.6
Installing Django project dependencies from requirement.txt file
sudo pip install --user -r requirement.txt
I have looked over internet for the similar issues but none of them helped.
I even have tried uninstalling pyOpenSSL using command:
pip uninstall pyOpenSSL
even this command is giving an error:
Traceback (most recent call last):
File "/Users/RitZz/Desktop/work/bin/pip", line 11, in <module>
load_entry_point('pip==19.1', 'console_scripts', 'pip')()
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2843, in load_entry_point
return ep.load()
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2434, in load
return self.resolve()
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2440, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pip/_internal/cli/main_parser.py", line 12, in <module>
from pip._internal.commands import (
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 20, in <module>
from pip._internal.download import PipSession
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pip/_internal/download.py", line 15, in <module>
from pip._vendor import requests, six, urllib3
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
from pip._vendor.urllib3.contrib import pyopenssl
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
import OpenSSL.SSL
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/Users/RitZz/Desktop/work/lib/python2.7/site-packages/OpenSSL/SSL.py", line 124, in <module>
SSL_ST_INIT = _lib.SSL_ST_INIT
AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
At few place it is mentioned to use:
sudo easy_install -U pyopenssl/pyOpenSSL
still getting same error.
even after deleting manually
> pyopenssl from python/2.7/site-packages/
and then reinstalling using command:
sudo pip install pyopenssl
it is not working, giving same error, (have also tried commands using --user flag)

Error while running odoo in mac

I am trying to install odoo in mac OS. I have installed all necessary requirements by referring a video on youtube and finally I tried to run server but I am getting an error like this:
lalits-MacBook-Pro:odoo lalitpatidar$ ./odoo-bin
Traceback (most recent call last):
File "./odoo-bin", line 5, in
__import__('pkg_resources').declare_namespace('odoo.addons')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1926, in declare_namespace
declare_namespace(parent)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1942, in declare_namespace
_handle_ns(packageName, path_item)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1912, in _handle_ns
loader.load_module(packageName); module.__path__ = path
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 246, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/Users/lalitpatidar/Desktop/v10/odoo/odoo/__init__.py", line 60, in
import modules
File "/Users/lalitpatidar/Desktop/v10/odoo/odoo/modules/__init__.py", line 8, in
from . import db, graph, loading, migration, module, registry
File "/Users/lalitpatidar/Desktop/v10/odoo/odoo/modules/graph.py", line 13, in
import odoo.osv as osv
File "/Users/lalitpatidar/Desktop/v10/odoo/odoo/osv/__init__.py", line 4, in
import osv
File "/Users/lalitpatidar/Desktop/v10/odoo/odoo/osv/osv.py", line 4, in
from ..exceptions import except_orm
File "/Users/lalitpatidar/Desktop/v10/odoo/odoo/exceptions.py", line 15, in
from tools.func import frame_codeinfo
File "/Users/lalitpatidar/Desktop/v10/odoo/odoo/tools/__init__.py", line 8, in
from misc import *
File "/Users/lalitpatidar/Desktop/v10/odoo/odoo/tools/misc.py", line 16, in
import passlib.utils
ImportError: No module named passlib.utils
I am new in odoo and stackoverflow as well so please avoid my little mistake if any.
You can install passlib module using pip
sudo pip install passlib

Error on QSTK.qstkstudy on Python 2.7.3

I am trying to install QSTK on my python 2.7.3. (on windows 10). During the installation, it seemed there was no problem and I did not face any errors. However, when I run the validation.py (here) to check it seems that QSTK.qstkstudu cannot be imported. Here is the error that I get while running validation.py:
QSTK is installed and can be imported
[...]
QSTK.qstkutil is installed and can be imported
File "C:\Python27\lib\site.py", line 372, in __call__
raise SystemExit(code)
SystemExit: Error : QSTK.qstkstudy can not be imported.
Does anyone have a clue what should I do?
The line in Validation.py which produces the error is:
import QSTK.qstkstudy.EventProfiler
If you try it directly in python, you can see what is missing. In my case it was tkinter.
>>> import QSTK.qstkstudy.EventProfiler
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/QSTK-0.2.8-py2.7.egg/QSTK/qstkstudy/EventProfiler.py", line 16, in <module>
import matplotlib.pyplot as plt
File "/usr/lib/python2.7/dist-packages/matplotlib/pyplot.py", line 114, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/usr/lib/python2.7/dist-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from matplotlib.externals.six.moves import tkinter as Tk
File "/usr/lib/python2.7/dist-packages/matplotlib/externals/six.py", line 199, in load_module
mod = mod._resolve()
File "/usr/lib/python2.7/dist-packages/matplotlib/externals/six.py", line 113, in _resolve
return _import_module(self.mod)
File "/usr/lib/python2.7/dist-packages/matplotlib/externals/six.py", line 80, in _import_module
__import__(name)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: No module named _tkinter, please install the python-tk package
I am on Linux so I did
sudo apt-get python-tk
Google how to install python tkinter in Windows.
Good luck

setuptools ez_setup return me UnicodeDecodeError

I'm using python 3.3 and Windows XP(32x).
I tried to install setuptools.
I write in command line:
py ez_setup.py install
And it return me error:
Traceback (most recent call last):
File "setup.py", line 19, in <module>
exec(init_file.read(), command_ns)
File "<string>", line 8, in <module>
File "c:\docume~1\jakov\locals~1\temp\tmpymerwg\setuptools-3.5.1\setuptools\_
init__.py", line 12, in <module>
from setuptools.extension import Extension
File "c:\docume~1\jakov\locals~1\temp\tmpymerwg\setuptools-3.5.1\setuptools\e
tension.py", line 7, in <module>
from setuptools.dist import _get_unpatched
File "c:\docume~1\jakov\locals~1\temp\tmpymerwg\setuptools-3.5.1\setuptools\d
st.py", line 16, in <module>
from setuptools.compat import numeric_types, basestring
File "c:\docume~1\jakov\locals~1\temp\tmpymerwg\setuptools-3.5.1\setuptools\c
mpat.py", line 19, in <module>
from SimpleHTTPServer import SimpleHTTPRequestHandler
File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
File "C:\Python27\lib\SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHan
ler
mimetypes.init() # try to read system mime.types
File "C:\Python27\lib\mimetypes.py", line 358, in init
db.read_windows_registry()
File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0x9e in position 6: ordinal
not in range(128)
Something went wrong during the installation.
See the error message above.
I am also using python 2.7, but I want to install setuptools for python 3.3.
I open my file with IDE and run it(because if you run code from cmd and you have both python2 and python3 it will run with python2 and iif you run it from IDE for python3 it will run in python3).
I really don't know if my explanation is true(because I don't have python2 on path), but I know that some files only work when you run it with IDE, and some only with cmd(or graphical).