Can't run snakeviz. What might be the problem here? - python

When I ran $ snakeviz code_profile.prof from CLI :
snakeviz web server started on 127.0.0.1:8080; enter Ctrl-C to exit http://127.0.0.1:8080/snakeviz/%2Fhome%2Fatmadeep%2FProjects%2FtrafficAI-master%2Fprofile_info-60.prof snakeviz: error: no web browser found: could not locate runnable browser
After some search, I tried running it in server only mode and got this error using --server argument :
Traceback (most recent call last): File "/home/atmadeep/anaconda3/envs/work-env/lib/python3.7/site-packages/tornado/web.py", line 1681, in _execute result = self.prepare() File "/home/atmadeep/anaconda3/envs/work-env/lib/python3.7/site-packages/tornado/web.py", line 2430, in prepare raise HTTPError(self._status_code) tornado.web.HTTPError: HTTP 404: Not Found
What might be the problem here? Is the profile generated corrupt or am I not understanding something related to snakeviz.
Note: I'm not running this code in jupyter-notebook.

So, here's the solution. from the console, run:
$python -m snakeviz profile.prof --server
When running from console, snakeviz needs to be called as shown above.

on a server you have to add --server argument and to click on the link in the terminal. Putting a threshold at 1/100 helps also.

Related

EZGmail not able to locate credentials.json file

I'm following along with Automate the Boring Stuff's "Sending and Receiving Email with the Gmail API" section, but I'm unable to get the ezgmail API set up. I'm using Jupyter Notebook if that makes any difference.
I've downloaded the gmail API, and run their Quickstart with no issues, but when I try to run the code from the book, I get an error that the system can't find the .json file. Here's my code, which is exactly as is it in the book (with the exception of the file path, which I've changed to 'C:\path\to' just for this):
import ezgmail, os
os.chdir(r'C:\path\to\PythonScripts\credentials_json_file') #I have correct file path in my code
ezgmail.init()
And I get the error:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-13-ed031accfb24> in <module>
1 import ezgmail, os
----> 2 os.chdir(r'C:\path\to\PythonScripts\credentials_json_file')
3 ezgmail.init()
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\path\to\\PythonScripts\\credentials_json_file'
I've double checked that the credentials file is in my current working directory with os.listdir, and the file shows up in the output. I've also tried to change the "credentials_json_file" part of the code to "credentials.json_file", remove the word file, json, etc., along with renaming the json file to credentials-gmail.json (as some related posts here suggest), but nothing works.
I've also tried running the code without the os.chdir line, but that just results in the following exception:
usage: ipykernel_launcher.py [--auth_host_name AUTH_HOST_NAME] [--noauth_local_webserver]
[--auth_host_port [AUTH_HOST_PORT [AUTH_HOST_PORT ...]]]
[--logging_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
ipykernel_launcher.py: error: unrecognized arguments: -f C:\path\to\AppData\Roaming\jupyter\runtime\kernel-5b1dd877-fb2d-4b67-8b7e-88a3d365dc4a.json
An exception has occurred, use %tb to see the full traceback.
SystemExit: 2
any help would be GREAT. I've been messing with this for way too long for such a simple introductory piece of code....

pywin32 cannot debug if project is packed into .exe

I have my project installed as a windows service and everything worked smoothly. I had some errors with using venv and pywin32, but eventually figuret that out. Stackoverflow link
However when I use pyinstaller to make onefile executable from it problems start occuring.
I use following command to create executable:
[Path_to_my_venv_pyinstaller] --onefile --hidden-import win32timezone myservice.py
Then I am executing it from cmd with install arg, service is installed.
However next step, executing it with start arg fails. Error message:
Starting service [Service_Name]
Error starting service: The service did not respond to the start or control request in a timely fashion.
So I tried debugging it with ``debug``` argument. It works normally, when I install service without executable, from source files. When service is installed from executable I am getting following error.
Debugging service [Service_Name] - press Ctrl+C to stop.
Traceback (most recent call last):
File "[Service]\[Service_Folder]\service.py", line 48, in <module>
File "lib\site-packages\win32\lib\win32serviceutil.py", line 640, in HandleCommandLine
File "lib\site-packages\win32\lib\win32serviceutil.py", line 461, in DebugService
AttributeError: module 'servicemanager' has no attribute 'Debugging'
[14252] Failed to execute script service
I found similar topic on stack, unanswered, link here. So the problem indeed lays in installing service from pyinstaller executable.
I have no idea, how to track error on this, Event Viewer does not display anything more than i could see from console.
Is there other way to debug a service?

AssertionError: ERROR: Call to stanford_ie exited with a non-zero code status

I am using the python wrapper for Stanford openIE created by philipperemy at here:https://github.com/philipperemy/Stanford-OpenIE-Python. However, I am using a window system so I use Cygwin to run the following code:
git clone https://github.com/philipperemy/Stanford-OpenIE-Python.git
cd Stanford-OpenIE-Python
echo "Barack Obama was born in Hawaii." > samples.txt
python main.py -f samples.txt
However, I meet the error saying that
AssertionError: ERROR: Call to stanford_ie exited with a non-zero code status.
I am not sure how to fix it. I used a java version of 1.8.0_121 and I checked if I used the updated version of this Github file by using $ git pull origin master.
Does anyone knows how to fix this problem?
Thanks in advance!
To be more specific, the complete error message in here:
$ python main.py -f samples.txt
Namespace(filename='samples.txt', generate_graph=False, verbose=False)
Traceback (most recent call last):
File "main.py", line 147, in <module>
exit(main(argv))
File "main.py", line 142, in main
entities_relations = stanford_ie(filename, verbose, generate_graphviz)
File "main.py", line 118, in stanford_ie
assert not java_process.returncode, 'ERROR: Call to stanford_ie exited with a non-zero code status.'
AssertionError: ERROR: Call to stanford_ie exited with a non-zero code status.
The straight answer coming from the author of Stanford-OpenIE-Python is that Windows OS is not supported by the library. Details here

key error when running local app example with dev_appserver.py

I am trying to run the appengine-endpoints-helloendpoints-python app locally using the google cloud platform SDK (which has been added to my path) using the command dev_appserver.py from the command line. It used to run perfectly, but now when I try, I get an error:
Error processing line 2 of
/Users/hannah/anaconda3/envs/py27/lib/python2.7/site-packages/grpc_google_pubsub_v1-0.8.1-py2.7-nspkg.pth:
Traceback (most recent call last):
File "/Users/hannah/anaconda3/envs/py27/lib/python2.7/site.py", line 161, in addpackage
exec line
File "<string>", line 1, in <module>
KeyError: 'google'
Remainder of file ignored
It's in a anaconda python2.7 environment. I've tried looking in site.py but I can't follow it back to a clear missing link.
The appcfg.py command used to deploy from the command line doens't work at all anymore. The command is not found.
bash: appcfg.py: command not found
As I said, I reinstalled and authorised the google cloud SDK and it is added to my path and that hasn't solved anything.
Oh finally, the error comes up whenever I run the dev_appserver.py command, not just with the example code from google.
Any tips would be appreciated

Receiving a ValueError: Unknown level when running GoogleScraper

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

Categories