Receiving a ValueError: Unknown level when running GoogleScraper - python

I recently decided to get to grips with some python and try to learn my way around the language but i've inevitably ran into a couple of problems that I was hoping someone could help me with.
Basically, I'm running on an OSx machine, I uninstalled the python that came with the operating system and used HomeBrew to download python 3.5.2, all that went successfully. Next I installed GoogleScraper (https://github.com/NikolaiT/GoogleScraper) which went well after a couple tries, but now, when I try to run a test query through terminal:
GoogleScraper -m http --keyword "apple" -v2
After the machines whizzes and buzzes for a few seconds, it pops out with an error:
GoogleScraper -m http --keyword "apple" -v2
Traceback (most recent call last):
File "/usr/local/bin/GoogleScraper", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.5/site-packages/GoogleScraper/core.py", line 173, in main
setup_logger(level=config.get('log_level').upper())
File "/usr/local/lib/python3.5/site-packages/GoogleScraper/log.py", line 23, in setup_logger
logger.setLevel(level)
File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/__init__.py", line 1255, in setLevel
self.level = _checkLevel(level)
File "/usr/local/Cellar/python3/3.5.2_1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/logging/__init__.py", line 187, in _checkLevel
raise ValueError("Unknown level: %r" % level)
ValueError: Unknown level: '2'
I've been trying to learn python online and am making some progress, but for the life of me can't figure out what any of that error means, hopefully one of you could at least point me in the direction of a solution.
Many thanks!

As per the source, the logging level is a string that corresponds to a syslog severity level, not a number indicating level of verboseness. This appears to work:
GoogleScraper -m http --keyword "apple" -v INFO

Related

Error processing line 1 of distutils-precedence.pth (no module named '_distutils_hack')

I'm on Windows 10 and working in a git-bash terminal with anaconda environment. When I open a new terminal, I'm immediately presented with:
Error processing line 1 of C:\Users\e360769\AppData\Local\miniforge3\lib\site-packages\distutils-precedence.pth:
Traceback (most recent call last):
File "C:\Users\e360769\AppData\Local\miniforge3\lib\site.py", line 169, in addpackage
exec(line)
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named '_distutils_hack'
Remainder of file ignored
This same error comes up any time I run "pip" or "python" on the command line. The command still executes correctly, but only after displaying that error. Note that this started after installing a collection of packages needed for a project I'm working with, and after investigating I found some people attributed this to the setuptools package (I have v41.2.0), but even when I uninstall it, the issue persists. Also note that this is the contents of my distutils-precedence.pth file:
import os; var = 'SETUPTOOLS_USE_DISTUTILS'; enabled = os.environ.get(var, 'local') == 'local'; enabled and __import__('_distutils_hack').add_shim();
I'm not sure this is actively (for now) causing any issues with executing my python scripts, etc., but I'd like to know what's going on and how to fix this. Would appreciate any help!

Writing a network Scanner with python using scapy

I am writing a simple network scanner with python using scapy following is my code :
import scapy.all as scapy
def scan(ip):
scapy.arping(ip)
scan("192.168.1.1/24")
Error I am getting :
Traceback (most recent call last):
File "ipScanner.py", line 10, in <module>
scan("192.168.1.1/24")
File "ipScanner.py", line 8, in scan
scapy.arping(ip)
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/layers/l2.py", line 648, in arping
filter="arp and arp[7] = 2", timeout=timeout, iface_hint=net, **kargs) # noqa: E501
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/sendrecv.py", line 553, in srp
filter=filter, nofilter=nofilter, type=type)
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/supersocket.py", line 242, in __init__
super(L2bpfListenSocket, self).__init__(*args, **kwargs)
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/supersocket.py", line 62, in __init__
(self.ins, self.dev_bpf) = get_dev_bpf()
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/core.py", line 114, in get_dev_bpf
raise Scapy_Exception("No /dev/bpf handle is available !")
scapy.error.Scapy_Exception: No /dev/bpf handle is available !
Exception ignored in: <function _L2bpfSocket.__del__ at 0x105984c20>
Traceback (most recent call last):
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/supersocket.py", line 139, in __del__
self.close()
File "/Users/omairkhan/opt/anaconda3/lib/python3.7/site-packages/scapy/arch/bpf/supersocket.py", line 211, in close
if not self.closed and self.ins is not None:
AttributeError: 'L2bpfSocket' object has no attribute 'ins'
Can anyone please help understand it.
NOTE: I am running it on mac OS.
I wrote this exact program when I first started programming with matching syntax, and it ran correctly on my systems when run as administrator. I develop on Linux and Windows rather than Mac, but I will offer what I can.
Are you running this script through your IDE or calling it from the shell?
I recommend only running it from the shell. This simply gives you more control over the files like specifying which version of python the script is, and if you need administrative privileges for a script, you can elevate the script permissions in the shell.
Also, in my OS, I was taught to always use, and have experienced the mistakes of forgetting this, always add:
#!/usr/bin/env python
as the first line of every script. At least in Linux, it tells the PC how to treat the file (it tells it to treat the file as a python file--yes I acknowledge that its already running it as python). I would check to see if that is valid for MacOS file system.
Most of what I have recommended so far comes down to no /dev/bpf handle is available, only ever being an issue for me when I'm not running script as an administrator (although Linux states permission denied). And I shouldn't leave out that using Anaconda on Windows in the past (before I understood the structure of my file systems) prevented me from using common modules like pygame and scapy. I could only guess in that case Anaconda prevented the PC from knowing where to find every piece of that module by making the computer think it had its own one of that module under Anaconda directory when it was in a different PATH.

Seahub fails to run initial start with ModuleNotFoundError

I'm currently trying to install seafile 7.1.4 on a Raspberry Pi 4 following the official guide (https://download.seafile.com/published/seafile-manual/deploy/using_mysql.md). The setup went smoothly, but when I try to start the seahub (./seahub start) for the first time I get the following error:
Traceback (most recent call last):
File "check_init_admin.py", line 351, in <module>
rpc = RPC()
File "check_init_admin.py", line 284, in __init__
import ccnet
ModuleNotFoundError: No module named 'ccnet'
I've been on google for the past two hours, but can't find a solution to this problem. What am I doing wrong?
I ran into the same issue. There's a bug in the 7.1.4 package. Seafile uses some local site packages. They (apparently) used to be under ${INSTALLPATH}/seafile/lib/python3.6/site-packages, now the are under ${INSTALLPATH}/seafile/lib/python3.7/site-packages
To fix:
open seahub.sh in the editor of your choice.
find the line that says:
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3.6/site-packages:${INSTALLPATH}/seafile/lib64/python3.6/site-packages:${INSTALLPATH}/seahub:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
change it to read:
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3.7/site-packages:${INSTALLPATH}/seafile/lib64/python3.7/site-packages:${INSTALLPATH}/seahub:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH

Ipython installation on 3.3 x64 errors

I don't have experience in downloading libraries, so any help is appreciated. I've got a fresh install of Python3.3 and am trying to get IPython for 64bit Windows 7. The IPython .exe installer ran fine and completed normally, but I can't access the program. I looked through their documentation, and tried the commands there, but
$ python setup.py install
returns invalid syntax, highlighting "setup". I thought the fix might be in the distribute library mentioned on the page, so I went to go try and get that first. However, using the script from distribute's install page revealed it's own errors, namely
Traceback (most recent call last):
File "C:\Python33\distribute_setup.py", line 541, in <module>
sys.exit(main())
File "C:\Python33\distribute_setup.py", line 537, in main
tarball = download_setuptools(download_base=options.download_base)
File "C:\Python33\distribute_setup.py", line 200, in download_setuptools
log.warn("Downloading %s", url)
File "C:\Python33\lib\distutils\log.py", line 47, in warn
self._log(WARN, msg, args)
File "C:\Python33\lib\distutils\log.py", line 30, in _log
if stream.errors == 'strict':
AttributeError: errors
I've been at it for a couple hours now, and I'm fresh out of ideas. What next?
It looks like you ran into Python bug 12967. You need to run distribute_setup.py outside of IDLE (i.e. in a command prompt).

Esky freezes after escalating permissions on windows 7

We're about to start using Esky to deploy updates to our application. On Windows 7, Esky appears to be unable to get the escalated privileges it needs to install an update.
I've narrowed it down to this simple script. It asks for escalated permissions, but will either freeze, or crash with the stacktrace below.
Script
import esky
import esky.sudo
class MyProgram(object):
#esky.sudo.allow_from_sudo()
def do_stuff(self):
pass
app = MyProgram()
sapp = esky.sudo.SudoProxy(app)
sapp.start()
sapp.do_stuff()
sapp.drop_root()
Stack Trace
$ python test.py
Traceback (most recent call last):
File "test.py", line 16, in <module>
sapp.start()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 125, in start
raise RuntimeError("sudo helper process terminated unexpectedly")
RuntimeError: sudo helper process terminated unexpectedly
$ python test.py
Traceback (most recent call last):
File "test.py", line 16, in <module>
sapp.start()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 140, in start
self.close()
File "c:\Python27\lib\site-packages\esky\sudo\__init__.py", line 156, in close
self.pipe.read()
File "c:\Python27\lib\site-packages\esky\sudo\sudo_base.py", line 123, in read
raise EOFError
EOFError
Does anyone know of a solution, or have any suggestions?
Using:
python 2.7.3
esky 0.9.7
3 years and no answer that is very sad :(
This is a bug in esky.
Esky works fine for me besides the fact that escalating privileges fails.
I'm used to programming in python3... so once I'm done updating Esky to be python 2 and 3 compatible I'm going to tackle this issue.
If anyone wants to solve this problem let's rock and roll! To the github issue tracker!
This is super late, but if anyone in the future has this problem, try running sudo python your_program.py.

Categories