PRAW induced SSL error when compiling Python script using py2exe - python

Python 2.7.11
Requests 2.9.1
Praw 3.4.0
I have a python script that uses PRAW (reddit API wrapper), I'm attempting to compile it into an .exe using py2exe.
Here is the current error that occurs when the .exe is run:
Traceback (most recent call last):
File "MYSCRIPTNAME.py", line 263, in <module>
File "<decorator-gen-51>", line 2, in login
File "praw\decorators.pyc", line 78, in wrap
File "praw\__init__.pyc", line 1455, in login
File "<decorator-gen-8>", line 2, in request_json
File "praw\decorators.pyc", line 116, in raise_api_exceptions
File "praw\__init__.pyc", line 620, in request_json
File "praw\__init__.pyc", line 451, in _request
File "praw\__init__.pyc", line 432, in handle_redirect
File "praw\handlers.pyc", line 146, in wrapped
File "praw\handlers.pyc", line 56, in wrapped
File "praw\handlers.pyc", line 102, in request
File "requests\sessions.pyc", line 576, in send
File "requests\adapters.pyc", line 447, in send
requests.exceptions.SSLError: [Errno 2] No such file or directory
Line 263 is r.login(user,pw) (r is r = praw.Reddit(userAgent))
Searching for other SSL issues on here and other places discussed adding cacert.pem. I tried this without resolution.

Related

AttributeError: module 'asyncio.coroutines' has no attribute '_is_coroutine'

I'm deploying a django app made with django channels using nginx, gunicorn and daphne. During deployment when I run python manage.py makemigrations, I get the following error. Could it be because the python version on my local machine was 3.7 and on remote ubuntu server is 3.5?
from cryptography import x509
/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/OpenSSL/crypto.py:12: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release of cryptography. Please upgrade your Python.
from cryptography import x509
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/apps.py", line 20, in ready
monkeypatch_django()
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/hacks.py", line 10, in monkeypatch_django
from .management.commands.runserver import Command as RunserverCommand
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/management/commands/runserver.py", line 11, in <module>
from channels.routing import get_default_application
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/routing.py", line 10, in <module>
from channels.http import AsgiHandler
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/http.py", line 152, in <module>
class AsgiHandler(base.BaseHandler):
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/channels/http.py", line 214, in AsgiHandler
#sync_to_async
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/asgiref/sync.py", line 375, in sync_to_async
return SyncToAsync(func, thread_sensitive=thread_sensitive)
File "/home/ubuntu/django/virtualenv2/lib/python3.5/site-packages/asgiref/sync.py", line 262, in __init__
self._is_coroutine = asyncio.coroutines._is_coroutine
AttributeError: module 'asyncio.coroutines' has no attribute '_is_coroutine'
The error is beacause of asgiref package that uses asyncio.coroutines._is_coroutine attribute since version 3.2.2.
You can install asgiref 3.2.1 and this problem doesn't happen.
pip install asgiref==3.2.1

coudn't find location of python module

I'm working with ubuntu, and it gives following error
Traceback (most recent call last):
File "SMAPylModules/SMAPylDriverPy.m/src/licensing.py", line 559, in <module>
File "SMAPylModules/SMAPylDriverPy.m/src/application.py", line 151, in run
File "SMAPylModules/SMAPylDriverPy.m/src/licensing.py", line 155, in execute
File "SMAPylModules/SMAPylDriverPy.m/src/licensing.py", line 228, in runCurrentUsageApp
File "SMAPyrModules/SMAPyrUtiPy.m/src/uti.py", line 37, in spawnAndWait
File "SMAPyrModules/SMAPyrUtiPy.m/src/utiSpawn.py", line 93, in spawnAndWait
File "SMAPyrModules/SMAPyrUtiPy.m/src/utiSpawnImpl.py", line 643, in spawnAndWait
File "SMAPyrModules/SMAPyrUtiPy.m/src/utiSpawnImpl.py", line 477, in __init__
File "SMAPyrModules/SMAPyrUtiPy.m/src/utiSpawnImpl.py", line 438, in popenWrap
I cannot find the SMAPyModules directory as well as modules such as licensing.py, utiSpawn.py etc.
Could you give me some solution or advice?
In the console:
sudo apt install lsb

Error when trying repo init on external drive on Ubuntu

I'm trying to init repo of Android ROM, but it returns following error on Ubuntu 16.04:
$ repo init -u git://github.com/AOSiP/platform_manifest.git -b pie
Get git://github.com/AOSiP/platform_manifest.git
Traceback (most recent call last):
File "/media/exthdd/AOSIP/.repo/repo/main.py", line 547, in <module>
_Main(sys.argv[1:])
File "/media/exthdd/AOSIP/.repo/repo/main.py", line 522, in _Main
result = repo._Run(argv) or 0
File "/media/exthdd/AOSIP/.repo/repo/main.py", line 184, in _Run
result = cmd.Execute(copts, cargs)
File "/media/exthdd/AOSIP/.repo/repo/subcmds/init.py", line 426, in Execute
self._SyncManifest(opt)
File "/media/exthdd/AOSIP/.repo/repo/subcmds/init.py", line 188, in _SyncManifest
m._InitGitDir(mirror_git=mirrored_manifest_git)
File "/media/exthdd/AOSIP/.repo/repo/project.py", line 2395, in _InitGitDir
self._UpdateHooks()
File "/media/exthdd/AOSIP/.repo/repo/project.py", line 2416, in _UpdateHooks
self._InitHooks()
File "/media/exthdd/AOSIP/.repo/repo/project.py", line 2446, in _InitHooks
os.path.relpath(stock_hook, os.path.dirname(dst)), dst)
File "/media/exthdd/AOSIP/.repo/repo/platform_utils.py", line 195, in symlink
return os.symlink(source, link_name)
OSError: [Errno 38] Function not implemented
It works when running on system drive, but I don't have enough space there.
Drive had exFAT filesystem, error gone on ext4.

Getting error while trying to execute jupyter-notebook

I'm getting an error while trying to execute jupyter-notebook in the console, the error happen here:
devnull = open(os.devnull, 'w')
FileNotFoundError: [Errno 2] No such file or directory: 'nul'
The strange thing is that it began to happen from one day to another, since until recently I could use jupyter-notebook perfectly, due to this error I uninstalled and then reinstalled anaconda, but the error persists.
My OS is Windows 10 and I installed the 64-bit installer with python 3.6
The Traceback is:
C:\Users\username\Anaconda3\Scripts>jupyter notebook
Traceback (most recent call last):
File "C:\Users\username\Anaconda3\Scripts\jupyter-notebook-script.py", line 5, in <module>
sys.exit(notebook.notebookapp.main())
File "C:\Users\username\Anaconda3\lib\site-packages\jupyter_core\application.py", line 267, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "C:\Users\username\Anaconda3\lib\site-packages\traitlets\config\application.py", line 657, in launch_instance
app.initialize(argv)
File "<decorator-gen-7>", line 2, in initialize
File "C:\Users\username\Anaconda3\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "C:\Users\username\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 1296, in initialize
self.init_webapp()
File "C:\Users\username\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 1093, in init_webapp
self.jinja_environment_options
File "C:\Users\username\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 167, in __init__
default_url, settings_overrides, jinja_env_options)
File "C:\Users\username\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 259, in init_settings
nbextensions_path=jupyter_app.nbextensions_path,
File "C:\Users\username\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 807, in nbextensions_path
from IPython.paths import get_ipython_dir
File "C:\Users\username\Anaconda3\lib\site-packages\IPython\__init__.py", line 49, in <module>
from .terminal.embed import embed
File "C:\Users\username\Anaconda3\lib\site-packages\IPython\terminal\embed.py", line 17, in <module>
from IPython.core.interactiveshell import DummyMod, InteractiveShell
File "C:\Users\username\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 62, in <module>
from IPython.utils import io
File "C:\Users\username\Anaconda3\lib\site-packages\IPython\utils\io.py", line 90, in <module>
devnull = open(os.devnull, 'w')
FileNotFoundError: [Errno 2] No such file or directory: 'nul'
Any help is welcome.

BeautifulSoup4 in Sagemath

I'm trying to perform web scraping with BS4 and then do some algebra work with the results in Sage 6.2 (in Lion 10.7.5). I assumed that /Applications/Sage-6.2.app/Contents/Resources/sage/sage -i beautifulsoup4 would work, but the result is
Attempting to download package beautifulsoup4
>>> Checking online list of optional packages.
[Traceback (most recent call last):
File "<stdin>", line 35, in <module>
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python/urllib.py", line 240, in retrieve
fp = self.open(url, data)
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python/urllib.py", line 208, in open
return getattr(self, name)(url)
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python/urllib.py", line 359, in open_http
return self.http_error(url, fp, errcode, errmsg, headers)
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python/urllib.py", line 376, in http_error
return self.http_error_default(url, fp, errcode, errmsg, headers)
File "<stdin>", line 17, in http_error_default
IOError: [Errno 404] Not Found: '//www.sagemath.org/spkg/optional/list'
Error: failed to download http://www.sagemath.org/spkg/optional/list, aborting
Next, I tried /Applications/Sage-6.2.app/Contents/Resources/sage/sage -sh <<< "easy_install --verbose pip" to get bs4 via pip. That succeeded; however /Applications/Sage-6.2.app/Contents/Resources/sage/local/bin/pip2.7 install beautifulsoup4 failed with error message
Traceback (most recent call last):
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/site.py", line 548, in <module>
main()
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/site.py", line 530, in main
known_paths = addusersitepackages(known_paths)
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/site.py", line 266, in addusersitepackages
user_site = getusersitepackages()
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/site.py", line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/site.py", line 231, in getuserbase
USER_BASE = get_config_var('userbase')
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/sysconfig.py", line 516, in get_config_var
return get_config_vars().get(name)
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/sysconfig.py", line 449, in get_config_vars
import re
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/Applications/Sage-6.2.app/Contents/Resources/sage/local/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Next, I tried upgrading to Sage 6.6. That went smoothly, as did the installation of bs4. However, when I opened the notebook, I was unable to run code cells, because the "Shift-Enter" command only registered as "Enter" and gave me a new line instead of evaluating the code. Additionally, there was no "evaluate" button. Any recommendations to solve any of these issues would be greatly appreciated.
Unfortunately, Sage has changed how it handles optional packages like BS so that older versions may not be able to use them. You can always go to a mirror, though, like http://mirrors.mit.edu/sage/spkg/optional/ download it, and put it in your (old Sage's) optional spkg directory and try doing sage -i path/to/file.
As to the notebook issue, that should be a matter of doing a "hard cache reset" in the browser due to different jQuery versions, see e.g. here.

Categories

Resources