I'm trying to learn Scrapy, and I'm running it on Mac OS X 10.11.2.
I'm following the tutorial, I've download the tutorial files and created a new Spider file as described here: http://doc.scrapy.org/en/1.0/intro/tutorial.html
When I try to run the spider, I get the following exception:
2015-12-11 19:04:05 [scrapy] INFO: Scrapy 1.0.3 started (bot: tutorial)
2015-12-11 19:04:05 [scrapy] INFO: Optional features available: ssl, http11
2015-12-11 19:04:05 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'tutorial.spiders', 'SPIDER_MODULES': ['tutorial.spiders'], 'BOT_NAME': 'tutorial'}
2015-12-11 19:04:06 [scrapy] INFO: Enabled extensions: CloseSpider, TelnetConsole, LogStats, CoreStats, SpiderState
Unhandled error in Deferred:
2015-12-11 19:04:06 [twisted] CRITICAL: Unhandled error in Deferred:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/scrapy/cmdline.py", line 150, in _run_command
cmd.run(args, opts)
File "/usr/local/lib/python2.7/site-packages/scrapy/commands/crawl.py", line 57, in run
self.crawler_process.crawl(spname, **opts.spargs)
File "/usr/local/lib/python2.7/site-packages/scrapy/crawler.py", line 153, in crawl
d = crawler.crawl(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1274, in unwindGenerator
return _inlineCallbacks(None, gen, Deferred())
--- <exception caught here> ---
File "/usr/local/lib/python2.7/site-packages/twisted/internet/defer.py", line 1128, in _inlineCallbacks
result = g.send(result)
File "/usr/local/lib/python2.7/site-packages/scrapy/crawler.py", line 71, in crawl
self.engine = self._create_engine()
File "/usr/local/lib/python2.7/site-packages/scrapy/crawler.py", line 83, in _create_engine
return ExecutionEngine(self, lambda _: self.stop())
File "/usr/local/lib/python2.7/site-packages/scrapy/core/engine.py", line 64, in __init__
self.scheduler_cls = load_object(self.settings['SCHEDULER'])
File "/usr/local/lib/python2.7/site-packages/scrapy/utils/misc.py", line 44, in load_object
mod = import_module(module)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/local/lib/python2.7/site-packages/scrapy/core/scheduler.py", line 6, in <module>
from queuelib import PriorityQueue
File "/usr/local/lib/python2.7/site-packages/queuelib/__init__.py", line 1, in <module>
from queuelib.queue import FifoDiskQueue, LifoDiskQueue
File "/usr/local/lib/python2.7/site-packages/queuelib/queue.py", line 5, in <module>
import sqlite3
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
from _sqlite3 import *
exceptions.ImportError: No module named _sqlite3
2015-12-11
19:04:06 [twisted] CRITICAL:
Initially I tought that I had a problem in my sqlite installation but it seems to be working if I run the command sqlite3 from the command line. Any ideas?
Apparently this iss a known homebrew problem, see here
I think you should reinstall homebrew's sqlite and python
Related
Hi I'm trying to make an executable using py2exe, I checked my script but cannot find the actual issue why below error is keep getting pop-up during building of exe
Building 'dist\py.exe'.
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\Test\pyexe\setup.py", line 15, in <module>
freeze(
File "C:\Python39\lib\site-packages\py2exe\__init__.py", line 176, in freeze
builder.build()
File "C:\Python39\lib\site-packages\py2exe\runtime.py", line 254, in build
self.build_archive(exe_path)
File "C:\Python39\lib\site-packages\py2exe\runtime.py", line 479, in build_archive
base = dist_path.rsplit('\\', 1)[0]
AttributeError: 'NoneType' object has no attribute 'rsplit'
Below is my setup.py script
from py2exe import freeze
from py_version import VERSION, DESCRIPTION # This is my own script
freeze(
console=[{"script": "py.py"}],
options={
"py2exe": {
"dist_dir": "dist",
"bundle_files": 1, # bundle as much as possible
"compressed": True,
}},
version_info={"version":VERSION,
"description":DESCRIPTION,
"company_name":"Priyanshu Kumar",
"copyright":"Opensource, credit goes to David Manthey",
"product_name":"Stand-Alone Python3 Interpreter",
"product_version":VERSION},
zipfile=None)
UPDATE:
I was searching on google for help and found that it should be <<<zipfile="None">>> instead of <<<zipfile=None>>>.
I changed it in my code but now got new error
Traceback (most recent call last):
File "C:\Users\User\PycharmProjects\Test\pyexe\setup.py", line 29, in <module>
options={
File "C:\Python39\lib\site-packages\py2exe\__init__.py", line 176, in freeze
builder.build()
File "C:\Python39\lib\site-packages\py2exe\runtime.py", line 273, in build
self.build_archive(libpath, delete_existing_resources=True)
File "C:\Python39\lib\site-packages\py2exe\runtime.py", line 397, in build_archive
resource.add(type=os.path.basename(pydll), name=1, value=pydll_bytes)
File "C:\Python39\lib\site-packages\py2exe\resources.py", line 49, in add
raise WindowsError(details) from None
OSError: [WinError 87] The parameter is incorrect.
Press any key to continue . . .
Whenever I try to open any apps on anaconda navigator (such as Spyder), I get this message. I am almost sure that is a problem with the path but I cannot resolve it.
Traceback (most recent call last):
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\utils.py", line 281, in create_window
main.setup()
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 772, in setup
from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\plugins\help\utils\sphinxify.py", line 34, in
from jinja2 import Environment, FileSystemLoader
File "C:\Users\Windows\anaconda3\lib\site-packages\jinja2\__init__.py", line 12, in
from .environment import Environment
File "C:\Users\Windows\anaconda3\lib\site-packages\jinja2\environment.py", line 25, in
from .defaults import BLOCK_END_STRING
File "C:\Users\Windows\anaconda3\lib\site-packages\jinja2\defaults.py", line 3, in
from .filters import FILTERS as DEFAULT_FILTERS # noqa: F401
File "C:\Users\Windows\anaconda3\lib\site-packages\jinja2\filters.py", line 13, in
from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (C:\Users\Windows\anaconda3\lib\site-packages\markupsafe\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Windows\anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\start.py", line 237, in main
mainwindow.main(options, args)
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1992, in main
mainwindow = create_window(MainWindow, app, splash, options, args)
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\utils.py", line 283, in create_window
if main.console is not None:
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 1088, in __getattr__
return self.get_plugin(self._INTERNAL_PLUGINS_MAPPING[attr])
File "C:\Users\Windows\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 165, in get_plugin
raise SpyderAPIError(f'Plugin "{plugin_name}" not found!')
spyder.api.exceptions.SpyderAPIError: Plugin "internal_console" not found!
I installed python-2.6 and then setuptools and finally pip-9.0.3 on my machine.I added the path of pip in my PATH variable.now when i type pip in my cmd, it returns this error.
C:\Users\Asus>pip
Traceback (most recent call last):
File "C:\Python26\Scripts\pip-script.py", line 11, in <module>
load_entry_point('pip==9.0.3', 'console_scripts', 'pip')()
File "build\bdist.win-amd64\egg\pkg_resources\__init__.py", line 572, in load_
entry_point
File "build\bdist.win-amd64\egg\pkg_resources\__init__.py", line 2769, in load
_entry_point
File "build\bdist.win-amd64\egg\pkg_resources\__init__.py", line 2422, in load
File "build\bdist.win-amd64\egg\pkg_resources\__init__.py", line 2428, in reso
lve
File "C:\Python26\lib\site-packages\pip-9.0.3-py2.6.egg\pip\__init__.py", line
45, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "C:\Python26\lib\site-packages\pip-9.0.3-py2.6.egg\pip\vcs\mercurial.py",
line 9, in <module>
from pip.download import path_to_url
File "C:\Python26\lib\site-packages\pip-9.0.3-py2.6.egg\pip\download.py", line
37, in <module>
from pip.utils.ui import DownloadProgressBar, DownloadProgressSpinner
File "C:\Python26\lib\site-packages\pip-9.0.3-py2.6.egg\pip\utils\ui.py", line
57, in <module>
_BaseBar = _select_progress_class(IncrementalBar, Bar)
File "C:\Python26\lib\site-packages\pip-9.0.3-py2.6.egg\pip\utils\ui.py", line
50, in _select_progress_class
six.text_type().join(characters).encode(encoding)
LookupError: unknown encoding: cp720
unfortunately this website www.pypi.org is unavailable in my country if that's the reason of the problem.
I seem to have some problems let python read key event, I wrote this piece of code
for recording while i have space down and stop when i've release it..
import pyaudio
import wave
import keyboard
CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK)
print("* recording")
frames = []
while keyboard.is_pressed('space'):
data = stream.read(CHUNK)
frames.append(data)
print("* done recording")
stream.stop_stream()
stream.close()
p.terminate()
wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
wf.setnchannels(CHANNELS)
wf.setsampwidth(p.get_sample_size(FORMAT))
wf.setframerate(RATE)
wf.writeframes(b''.join(frames))
wf.close()
But when running this code, I get this error message.
python sound_record.py
* recording
Traceback (most recent call last):
File "sound_record.py", line 24, in <module>
while keyboard.is_pressed('space'):
File "/usr/local/lib/python2.7/site-packages/keyboard/__init__.py", line 162, in is_pressed
_listener.start_if_necessary()
File "/usr/local/lib/python2.7/site-packages/keyboard/_generic.py", line 36, in start_if_necessary
self.init()
File "/usr/local/lib/python2.7/site-packages/keyboard/__init__.py", line 112, in init
_os_keyboard.init()
File "/usr/local/lib/python2.7/site-packages/keyboard/_nixkeyboard.py", line 110, in init
build_device()
File "/usr/local/lib/python2.7/site-packages/keyboard/_nixkeyboard.py", line 106, in build_device
ensure_root()
File "/usr/local/lib/python2.7/site-packages/keyboard/_nixcommon.py", line 163, in ensure_root
raise ImportError('You must be root to use this library on linux.')
ImportError: You must be root to use this library on linux.
And when i do it using sudo:
sudo !!
sudo python sound_record.py
Password:
* recording
Traceback (most recent call last):
File "sound_record.py", line 24, in <module>
while keyboard.is_pressed('space'):
File "/usr/local/lib/python2.7/site-packages/keyboard/__init__.py", line 162, in is_pressed
_listener.start_if_necessary()
File "/usr/local/lib/python2.7/site-packages/keyboard/_generic.py", line 36, in start_if_necessary
self.init()
File "/usr/local/lib/python2.7/site-packages/keyboard/__init__.py", line 112, in init
_os_keyboard.init()
File "/usr/local/lib/python2.7/site-packages/keyboard/_nixkeyboard.py", line 110, in init
build_device()
File "/usr/local/lib/python2.7/site-packages/keyboard/_nixkeyboard.py", line 107, in build_device
device = aggregate_devices('kbd')
File "/usr/local/lib/python2.7/site-packages/keyboard/_nixcommon.py", line 141, in aggregate_devices
uinput = make_uinput()
File "/usr/local/lib/python2.7/site-packages/keyboard/_nixcommon.py", line 27, in make_uinput
uinput = open("/dev/uinput", 'wb')
IOError: [Errno 1] Operation not permitted: '/dev/uinput'
So why am I getting this error message?
You appear to be using the Python package keyboard, whose description is:
Hook and simulate keyboard events on Windows and Linux
If you want to do work with keyboard events on MacOS, you'll need to find a package that does that.
I installed anaconda 4.3.0 for OSX, Python 3.6. Everything with the install seemed to go fine. However when I try to start jupiter notebook I get:
Traceback (most recent call last):
File "/Users/joe/anaconda3/bin/jupyter-notebook", line 4, in <module>
import notebook.notebookapp
File "/Users/joe/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 63, in <module>
from .services.contents.manager import ContentsManager
File "/Users/joe/anaconda3/lib/python3.6/site-packages/notebook/services/contents/manager.py", line 16, in <module>
from nbformat import sign, validate, ValidationError
File "/Users/joe/anaconda3/lib/python3.6/site-packages/nbformat/__init__.py", line 33, in <module>
from .validator import validate, ValidationError
File "/Users/joe/anaconda3/lib/python3.6/site-packages/nbformat/validator.py", line 12, in <module>
from jsonschema import ValidationError
File "/Users/joe/anaconda3/lib/python3.6/site-packages/jsonschema/__init__.py", line 18, in <module>
from jsonschema.validators import (
File "/Users/joe/anaconda3/lib/python3.6/site-packages/jsonschema/validators.py", line 8, in <module>
import requests
File "/Users/joe/anaconda3/lib/python3.6/site-packages/requests/__init__.py", line 52, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/Users/joe/anaconda3/lib/python3.6/site-packages/requests/packages/urllib3/contrib/pyopenssl.py", line 47, in <module>
import OpenSSL.SSL
File "/Users/joe/anaconda3/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/Users/joe/anaconda3/lib/python3.6/site-packages/OpenSSL/crypto.py", line 13, in <module>
from cryptography.hazmat.primitives.asymmetric import dsa, rsa
File "/Users/joe/anaconda3/lib/python3.6/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 14, in <module>
from cryptography.hazmat.backends.interfaces import RSABackend
File "/Users/joe/anaconda3/lib/python3.6/site-packages/cryptography/hazmat/backends/__init__.py", line 7, in <module>
import pkg_resources
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources.py", line 1423, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
When I try to run conda I get
Traceback (most recent call last):
File "/Users/joe/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 617, in conda_exception_handler
return_value = func(*args, **kwargs)
File "/Users/joe/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 85, in _main
from ..base.context import context
File "/Users/joe/anaconda3/lib/python3.6/site-packages/conda/base/context.py", line 17, in
from .._vendor.auxlib.path import expand
File "/Users/joe/anaconda3/lib/python3.6/site-packages/conda/_vendor/auxlib/path.py", line 8, in
import pkg_resources
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources.py", line 1423, in
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/joe/anaconda3/bin/conda", line 6, in
sys.exit(conda.cli.main())
File "/Users/joe/anaconda3/lib/python3.6/site-packages/conda/cli/main.py", line 167, in main
return conda_exception_handler(_main, *args)
File "/Users/joe/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 633, in conda_exception_handler
print_unexpected_error_message(e)
File "/Users/joe/anaconda3/lib/python3.6/site-packages/conda/exceptions.py", line 543, in print_unexpected_error_message
from conda.base.context import context
File "/Users/joe/anaconda3/lib/python3.6/site-packages/conda/base/context.py", line 17, in
from .._vendor.auxlib.path import expand
File "/Users/joe/anaconda3/lib/python3.6/site-packages/conda/_vendor/auxlib/path.py", line 8, in
import pkg_resources
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pkg_resources.py", line 1423, in
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
I did a simple remove and reinstall but the problem persists after the reinstall. I would try to run anaconda-clean but since conda does not work, I can't install it. Any advice?