jep.JepException: <class 'NameError'>: name 'ssl' is not defined
- OS Platform, Distribution, and Version: Ubuntu 16.0.4
- Python Distribution and Version: 3.5
- Java Distribution and Version: java version "1.8.0_161"
I have python file which write log in amazon cloud watch logs, when I run python file it work well and creates logs into cloud watch. But when I started same things into scala so I used JEP to called my python file into scala all work well but when I called jep.invove() with class name and parameters it show following error
[error] (run-main-0) jep.JepException: <class 'NameError'>: name 'ssl' is not defined
[error] jep.JepException: <class 'NameError'>: name 'ssl' is not defined
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/vendored/requests/packages/urllib3/util/ssl_.resolve_cert_reqs(ssl_.py:157)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/vendored/requests/packages/urllib3/connection.connect(connection.py:206)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool._validate_conn(connectionpool.py:761)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool._make_request(connectionpool.py:341)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/vendored/requests/packages/urllib3/connectionpool.urlopen(connectionpool.py:544)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/vendored/requests/adapters.send(adapters.py:370)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/vendored/requests/sessions.send(sessions.py:573)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/endpoint._get_response(endpoint.py:213)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/retryhandler._check_caught_exception(retryhandler.py:359)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/retryhandler.__call__(retryhandler.py:223)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/retryhandler.__call__(retryhandler.py:317)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/retryhandler._should_retry(retryhandler.py:269)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/retryhandler.__call__(retryhandler.py:251)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/retryhandler.__call__(retryhandler.py:183)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/hooks._emit(hooks.py:210)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/hooks.emit(hooks.py:227)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/endpoint._needs_retry(endpoint.py:265)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/endpoint._send_request(endpoint.py:172)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/endpoint.make_request(endpoint.py:143)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/client._make_api_call(client.py:599)
[error] at /home/testName/.local/lib/python3.5/site-packages/botocore/client._api_call(client.py:314)
[error] at jep.Jep.invoke(Native Method)
[error] at jep.Jep.invoke(Jep.java:531)
[error] at test$.delayedEndpoint$test$1(test.scala:10)
[error] at test$delayedInit$body.apply(test.scala:2)
[error] at scala.Function0.apply$mcV$sp(Function0.scala:34)
[error] at scala.Function0.apply$mcV$sp$(Function0.scala:34)
[error] at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error] at scala.App.$anonfun$main$1$adapted(App.scala:76)
[error] at scala.collection.immutable.List.foreach(List.scala:389)
[error] at scala.App.main(App.scala:76)
[error] at scala.App.main$(App.scala:74)
[error] at test$.main(test.scala:2)
[error] at test.main(test.scala)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:498)
[error] at sbt.Run.invokeMain(Run.scala:93)
[error] at sbt.Run.run0(Run.scala:87)
[error] at sbt.Run.execute$1(Run.scala:65)
[error] at sbt.Run.$anonfun$run$4(Run.scala:77)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
[error] at sbt.TrapExit$App.run(TrapExit.scala:252)
[error] at java.lang.Thread.run(Thread.java:748)
[error] java.lang.RuntimeException: Nonzero exit code: 1
[error] at sbt.Run$.executeTrapExit(Run.scala:124)
[error] at sbt.Run.run(Run.scala:77)
[error] at sbt.Defaults$.$anonfun$bgRunMainTask$6(Defaults.scala:1147)
[error] at sbt.Defaults$.$anonfun$bgRunMainTask$6$adapted(Defaults.scala:1142)
[error] at sbt.internal.BackgroundThreadPool.$anonfun$run$1(DefaultBackgroundJobService.scala:366)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] at scala.util.Try$.apply(Try.scala:209)
[error] at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:289)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (Compile / runMain) Nonzero exit code: 1
[error] Total time: 3 s, completed 23 Mar, 2018 5:05:09 PM
What is you LD_PRELOAD environmental variable set to?
I set this LD_PRELOAD variable :
export LD_PRELOAD=/usr/lib/python3.5/config-3.5m-x86_64-linux-gnu/libpython3.5.so
Your LD_PRELOAD variable looks reasonable.
Glancing at the urllib3 code, it looks like they attempted to import ssl and when it failed they ignored it resulting in the exception you are getting(https://github.com/shazow/urllib3/blob/master/urllib3/util/ssl_.py#L47).
It would be helpful if we could see what error occurred importing ssl, can you import ssl using jep.eval or early in your script and report what error you see?
I would also be curious to know if importing ssl on the jep command line produces an error.
I added this line
jep.eval("import ssl") but it show following error :
[error] (run-main-0) jep.JepException: <class 'ImportError'>: No module named '_ssl'
[error] jep.JepException: <class 'ImportError'>: No module named '_ssl'
[error] at /usr/local/lib/python3.5/ssl.<module>(ssl.py:98)
[error] at <string>.<module>(<string>:1)
[error] at jep.Jep.eval(Native Method)
[error] at jep.Jep.eval(Jep.java:609)
[error] at test$.delayedEndpoint$test$1(test.scala:5)
[error] at test$delayedInit$body.apply(test.scala:2)
[error] at scala.Function0.apply$mcV$sp(Function0.scala:34)
[error] at scala.Function0.apply$mcV$sp$(Function0.scala:34)
[error] at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error] at scala.App.$anonfun$main$1$adapted(App.scala:76)
[error] at scala.collection.immutable.List.foreach(List.scala:389)
[error] at scala.App.main(App.scala:76)
[error] at scala.App.main$(App.scala:74)
[error] at test$.main(test.scala:2)
[error] at test.main(test.scala)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:498)
[error] at sbt.Run.invokeMain(Run.scala:93)
[error] at sbt.Run.run0(Run.scala:87)
[error] at sbt.Run.execute$1(Run.scala:65)
[error] at sbt.Run.$anonfun$run$4(Run.scala:77)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
[error] at sbt.TrapExit$App.run(TrapExit.scala:252)
[error] at java.lang.Thread.run(Thread.java:748)
[error] java.lang.RuntimeException: Nonzero exit code: 1
[error] at sbt.Run$.executeTrapExit(Run.scala:124)
[error] at sbt.Run.run(Run.scala:77)
[error] at sbt.Defaults$.$anonfun$bgRunMainTask$6(Defaults.scala:1147)
[error] at sbt.Defaults$.$anonfun$bgRunMainTask$6$adapted(Defaults.scala:1142)
[error] at sbt.internal.BackgroundThreadPool.$anonfun$run$1(DefaultBackgroundJobService.scala:366)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error] at scala.util.Try$.apply(Try.scala:209)
[error] at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:289)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (Compile / runMain) Nonzero exit code: 1
[error] Total time: 4 s, completed 24 Mar, 2018 7:49:47 PM
@bsteffensmeier did you find any thing related this issues in my python3.5 console this both work well
import ssl
import _ssl
@bsteffensmeier said
I would also be curious to know if importing ssl on the jep command line produces an error.
Please use the jep console as @bsteffensmeier mentioned at the bottom of his previous post. python setup.py install will create a command line script named jep which is basically a Python console/cmd line interpreter with Jep support. We need to know if the import ssl works in the jep console or not before we proceed further.
Did you make any progress on this?
Closing due to inactivity.
Hi,
i had the same issue when running my ansible playbook as below :-
---
- hosts: localhost
tasks:
- name: Get more host facts
local_action:
module: ec2_instance_facts
instance_ids:
- <ec2-instance-id>
region: <ec2-instance region>
register: instance
error :- [WARNING]: Skipping plugin (~/python2.7/site-packages/ansible/plugins/callback/grafana_annotations.py) as it seems to be invalid: 'module' object has no attribute 'HTTPSHandler' [WARNING]: Skipping plugin (~/python2.7/site-packages/ansible/plugins/callback/hipchat.py) as it seems to be invalid: 'module' object has no attribute 'HTTPSHandler' [WARNING]: Skipping plugin (~/python2.7/site-packages/ansible/plugins/callback/slack.py) as it seems to be invalid: 'module' object has no attribute 'HTTPSHandler' [WARNING]: Skipping plugin (~/python2.7/site-packages/ansible/plugins/callback/splunk.py) as it seems to be invalid: 'module' object has no attribute 'HTTPSHandler' [WARNING]: Skipping plugin (~/python2.7/site-packages/ansible/plugins/callback/sumologic.py) as it seems to be invalid: 'module' object has no attribute 'HTTPSHandler'
File "~//python2.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
NameError: global name 'ssl' is not defined
@mohamad7788 can you run the jep command from the command line and try to import ssl and see if there are any errors.