Scrapy - Error while creating project - DDL Load failed - python

I am trying for a longer time.Please do help.
I installed scrapy using conda.
I tested pip show scrapy in the command line and it is working perfectly.
While i type import scrapy in the python terminal it is not showing any error.
But if i create a project or execute an existing project of scrapy i get the following error:
C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\commands\deploy.py:16: ScrapyDeprecationWarning: Module `scrapy.command` is deprecated, use `scrapy.commands` instead
from scrapy.command import ScrapyCommand
Traceback (most recent call last):
File "C:\Users\Nikeshh\Anaconda2\Scripts\scrapy-script.py", line 10, in <module>
sys.exit(execute())
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\cmdline.py", line 149, in execute
cmd.crawler_process = CrawlerProcess(settings)
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\crawler.py", line 252, in __init__
log_scrapy_info(self.settings)
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\utils\log.py", line 149, in log_scrapy_info
for name, version in scrapy_components_versions()
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\utils\versions.py", line 35, in scrapy_components_versions
("pyOpenSSL", _get_openssl_version()),
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\utils\versions.py", line 43, in _get_openssl_version
import OpenSSL
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\OpenSSL\crypto.py", line 16, in <module>
from OpenSSL._util import (
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\OpenSSL\_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 13, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed: The operating system cannot run %1.
I am using scrapy startproject tutorial to create a project.How to solve this error?
Is there any specific way to execute the scrapy code?
Even when i add openssl using conda i am getting the same error

It looks like you need the OpenSSL libraries that are used for encryption.
You could go and download these from somewhere here: https://wiki.openssl.org/index.php/Binaries
Alternatively I think the installer for git will install OpenSSL by default, which you can get here: https://git-scm.com/download
However, since you're using Anaconda, OpenSSL should also be available with conda: https://anaconda.org/anaconda/openssl
Hope this helps!

Related

ImportError: cannot import name 'HTTPSHandler' from 'urllib.request' for windows

I found 0 topics about this issue for Windows, only for Ubuntu, MAc etc.
When I try to install any package via Pycharm, e.g. urllib, matplotlib, heidi, I get the exact same error message as below.
Project interpreter is Anaconda Python 3.7.
Any idea how this can solved?
Error: Traceback (most recent call last):
File "E:\Download\PROGIK\Charm Community Edition 2018.3.5\helpers\packaging_tool.py", line 73, in run_pip
runpy.run_module(module_name, run_name='__main__', alter_sys=True)
File "E:\Download\PROGIK\Anaconda\lib\runpy.py", line 201, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "E:\Download\PROGIK\Anaconda\lib\runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "E:\Download\PROGIK\Anaconda\lib\runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\vcs\subversion.py", line 9, in <module>
from pip.index import Link
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\wheel.py", line 35, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\_vendor\distlib\scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "E:\Download\PROGIK\Anaconda\lib\site-packages\pip\_vendor\distlib\compat.py", line 66, in <module>
from urllib.request import (urlopen, urlretrieve, Request, url2pathname,
ImportError: cannot import name 'HTTPSHandler' from 'urllib.request' (E:\Download\PROGIK\Anaconda\lib\urllib\request.py)
Edit: with pip I have only problem with matplotlib, which is another topic:
Cannot install matplotlib. Fatal error LNK1181, Visual Studio fail
Simply went into packages folder and deleted matplotlib package manually because could not make it display graphs in Jupyter (didnt try in Pycharm). Trying to reinstall it now, hopefully it will fix the issue.
To install packages whithin anaconda environment under Windows10, you should use "Anaconda prompt" (find it in win menu)
It starts (Base) venv by default and installs packages in it. Therefore using Python interpreter distributed with Anaconda you will be able to import them with no side actions.
Besides matplotlib is installed there by default

Unable to run AWS CLI: ImportError: cannot import name 'HTTPClientError'

I recently tried to install some Python Packages (Superset, Bonobo amongst others) after which my AWS cli stopped working with the below issue:
user#ubuntu-machine:~$ aws --version
Traceback (most recent call last):
File "/home/user/.local/bin/aws", line 27, in <module>
sys.exit(main())
File "/home/user/.local/bin/aws", line 23, in main
return awscli.clidriver.main()
File "/home/user/.local/lib/python3.6/site-packages/awscli/clidriver.py", line 58, in main
driver = create_clidriver()
File "/home/user/.local/lib/python3.6/site-packages/awscli/clidriver.py", line 68, in create_clidriver
event_hooks=session.get_component('event_emitter'))
File "/home/user/.local/lib/python3.6/site-packages/awscli/plugin.py", line 44, in load_plugins
modules = _import_plugins(plugin_mapping)
File "/home/user/.local/lib/python3.6/site-packages/awscli/plugin.py", line 61, in _import_plugins
module = __import__(path, fromlist=[module])
File "/home/user/.local/lib/python3.6/site-packages/awscli/handlers.py", line 20, in <module>
from awscli.paramfile import register_uri_param_handler
File "/home/user/.local/lib/python3.6/site-packages/awscli/paramfile.py", line 18, in <module>
from botocore.httpsession import URLLib3Session
File "/home/user/.local/lib/python3.6/site-packages/botocore/httpsession.py", line 24, in <module>
from botocore.exceptions import (
ImportError: cannot import name 'HTTPClientError'
Inorder to restore it I've tried un-installing all packages mentioned in What is the easiest way to remove all packages installed by pip?, and only reinstalled awscli. Still I run into the same issue.
Did you uninstall botocore as well before you uninstall and reinstall the aws cli? Sometime you can get in this situation as when you install other packages it relies on different version of botocore and conflict with the one that aws cli needs. In these situations I think you want to use python virtual environment for your project to keep your project dependencies isolate from the global python environment which is where aws cli botocore resides.

django.contrib.gis.geos.error.GEOSException: Could not parse version info string

I installed gdal on Mac as follows:
brew install -v gdal
However when I run my program (which I was able to successfully run on Linux), it gives me the following errors:
File "/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/tesor/Desktop/test/api-server/api-server/lib/python2.7/site-packages/django/contrib/gis/admin/__init__.py", line 5, in <module>
from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin
File "/Users/tesor/Desktop/test/api-server/api-server/lib/python2.7/site-packages/django/contrib/gis/admin/options.py", line 2, in <module>
from django.contrib.gis.admin.widgets import OpenLayersWidget
File "/Users/tesor/Desktop/test/api-server/api-server/lib/python2.7/site-packages/django/contrib/gis/admin/widgets.py", line 4, in <module>
from django.contrib.gis.geos import GEOSException, GEOSGeometry
File "/Users/tesor/Desktop/test/api-server/api-server/lib/python2.7/site-packages/django/contrib/gis/geos/__init__.py", line 18, in <module>
HAS_GEOS = geos_version_info()['version'] >= '3.3.0'
File "/Users/tesor/Desktop/test/api-server/api-server/lib/python2.7/site-packages/django/contrib/gis/geos/libgeos.py", line 196, in geos_version_info
raise GEOSException('Could not parse version info string "%s"' % ver)
django.contrib.gis.geos.error.GEOSException: Could not parse version info string "3.6.3-CAPI-1.10.3 80c13047"
I cannot figure out what's happening. The version of python is Python 2.7.15. I understand that the issue is related to the version of GDAL, but how can I solve this problem?
I need gdal 1.10.1.
The fix for me was to make sure I was running python 3.
I exited my pipenv and re-entered it. Also doublecheck pyenv is properly installed.

Error while building ns-3

I am trying to install ns-3 by tarball but when I try to build with following command
./build.py --enable-examples --enable-tests
as given in manual I get following error:
Traceback (most recent call last):
File "./build.py", line 170, in <module>
sys.exit(main(sys.argv))
File "./build.py", line 111, in main
config = dom.parse(dot_config)
File "/usr/local/lib/python2.7/xml/dom/minidom.py", line 1917, in parse
from xml.dom import expatbuilder
File "/usr/local/lib/python2.7/xml/dom/expatbuilder.py", line 32, in <module>
from xml.parsers import expat
File "/usr/local/lib/python2.7/xml/parsers/expat.py", line 4, in <module>
from pyexpat import *
ImportError: /usr/local/lib/python2.7/lib-dynload/pyexpat.so: undefined symbol: PyUnicodeUCS2_DecodeUTF
I know this error is related to python but not able to resolve after doing a lot of Google search.Can anybody help me how to proceed further?
Solved:
After exhausted research I found Python for Linux default setting is UCS2.
I rebuilt Python from source using
./configure --enable-unicode=ucs4
to force compile using UCS4.
Here is the link.

Django: ImportError: cannot import name _compare_digest

I have installed Django 1.6.5 with PIP and Python 2.7.8 from the website.
I ran django-admin.py startproject test123, switched to test123 directory, and ran the command python manage.py runserver, then i get this:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/conf/__init__.py", line 50, in _setup
self._configure_logging()
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/conf/__init__.py", line 72, in _configure_logging
from django.utils.log import DEFAULT_LOGGING
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/utils/log.py", line 7, in <module>
from django.views.debug import ExceptionReporter, get_exception_reporter_filter
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/views/debug.py", line 10, in <module>
from django.http import (HttpResponse, HttpResponseServerError,
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/http/__init__.py", line 2, in <module>
from django.http.request import (HttpRequest, QueryDict, UnreadablePostError,
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/http/request.py", line 11, in <module>
from django.core import signing
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/core/signing.py", line 45, in <module>
from django.utils.crypto import constant_time_compare, salted_hmac
File "/Library/Python/2.7/site-packages/Django-1.6.5-py2.7.egg/django/utils/crypto.py", line 6, in <module>
import hmac
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/hmac.py", line 8, in <module>
from operator import _compare_digest as compare_digest
ImportError: cannot import name _compare_digest
Found out that operator is a standard python library. Why cant it not import it?
P.S. I did try it in the command line, I can import the operator module, but I get an error on this statement: from operator import _compare_digest as compare_digest
Followed this SO answer:
Uninstall python.org version of python2.7 in favor of default OS X python2.7
Then changed my .bash_profile Python path to /usr/lib/python for the default OSX python path.
Uninstalled Django and MySQL-Python:
sudo pip uninstall django
sudo pip uninstall MySQL-Python
And then again reinstalled everything, but with MySQL-Python being the first and second Django.
After these steps, everything is working.
I get this error with anaconda as my default python and django1.7 while trying to use startproject.
I deleted the venv and recreated it with
virtualenv -p /usr/bin/python2.7 venv
startproject was working again.
You most likely have another file named operator.py on your PYTHONPATH (probably in the current working directory), which shadows the standard library operator module..
Remove or rename the file.
For those not wanting to switch to Apple's python, simply deleting the virtualenv and rebuilding it worked fine for me.
Tip: Don't forget to pip freeze > requirements.txt first if you aren't already tracking your package requirements. That way you can pip install -r requirements.txt to get up and running again quickly.

Categories