Python build failed - python

I was trying to build python from source. Durring
$make test
this error arose and caused the build to fail.
====================================================================== ERROR: test_idna (test.test_socket.GeneralModuleTests)
---------------------------------------------------------------------- Traceback (most recent call last): File
"/home/h/Downloads/Python-3.4.2/Lib/test/test_socket.py", line 1287,
in test_idna
socket.gethostbyname('испытание.python.org') socket.gaierror: [Errno -5] No address associated with hostname
---------------------------------------------------------------------- Ran 506 tests in 150.098s
FAILED (errors=1, skipped=24) test test_socket failed make: *** [test]
Error 1
Im sketched by having the russian URL in the source of python. Was python hacked?
what is this? It translates into ispytanie.python.org
but i still have no clue why its there.
UPDATE:
http://ispytanie.python.org/
the page which was the translation, of the Russian page, no longer works.
anyone who follows the directions for a Linux install, running $make test
will likely encounter this error.

I edited Python-3.4.2/Lib/test/test_socket.py and removed 3 instances of Russian URLs, replacing them with 'python.org' which now allows for $make test to succeed.

Related

Get more info out of a Python3 OSError

I am using Python3 on Ubuntu with the HID module python3-hid.
If I use it to open a device, I simply get back:
OSError: open failed
Which prompted me to handle the exception, and see if I can get more information out of it:
try:
h.open(vend, prod)
except OSError as error :
print(error)
print(error.strerror)
print(error.filename)
sys.exit(1)
To my surprise, no further information was available, as both strerror and filename were None.
open failed
None
None
NOTE: My open() succeeds when I run as root, so I know this is a permission thing. But why can't this OSError tell me that it is permission related?
How do I get all the details (specific reason of failure, and filename involved) out of an OSError?
UPDATE: The traceback leads to hid.pyx file:
Traceback (most recent call last):
File "/tmp/./tst.py", line 30, in <module>
h.open(vend, prod)
File "hid.pyx", line 66, in hid.device.open
I am not sure why my system can't find the hid.pyx file.
$ dpkg -S hid.pyx
dpkg-query: no path found matching pattern *hid.pyx*
Checking the upstream package from Ubuntu... it turns out that python3-hid is part of the software for a crypto coin wallet? Strange. I think I will skip using this module, and maybe write directly in C, using libhidapi-hidraw which this python module also uses.

pywin32 ModuleNotFoundError in python3 docx script

When running a python3 script that generates a word document on a windows machine the following error occurs:
08:53:23 Traceback (most recent call last):
08:53:23 File "c:\python\venv\py3-32-report-generator\lib\site-packages\win32com\client\gencache.py", line 236, in GetModuleForCLSID
08:53:23 __import__(sub_mod_name)
08:53:23 ModuleNotFoundError: No module named 'win32com.gen_py.00020905-0000-0000-C000-000000000046x0x8x4.ListTemplates'
The error only occurs once in a while, thats what confuses me so much.
It reminded me of a similar AttributeError that could be resolved by deleting the gen_py folder in ../AppData/Local/Temp/. Unfortunately this fix doesnt seem to help here.
If you need any more info describing the problem let me know. Thanks:)

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

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.

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....

web.py on apache gives a Socket operation on non-socket

What can cause this error?
I get these errors every time a client accesses my server.
it hapens only once in each request.
the script runs with seemingly no problems, but i don't know if there are hidden implications or complication that result from this error that i'm not aware of.
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/flup/server/fcgi_base.py", line 982, in _setupSocket
sock.getpeername()
fcgi_base
error: [Errno 88] Socket operation on non-socket
i'm running python as cgi ,web.py, linux (ubuntu12)
what can be the cause of this error?
How can I investigate it?

Categories