Can anyone help me understand why python's logging module creates a StreamHandler on import, but only on some distributions? weird.. (note: happens on any python3)
On Mac
Python 3.5.6 (default, Dec 19 2019, 14:59:39)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.getLogger().handlers
[<logging.StreamHandler object at 0x108fc2630>]
Linux:
Python 3.7.4 (default, Jan 3 2020, 19:27:19)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> logging.getLogger().handlers
[]
>>>
I can't seem to find any explanation about this behavior difference!
EDIT:
A bit more investigation suggests that some module installed in the virtualenv is causing this behavior mismatch. I created a fresh one with the same python interpreter and no handler gets made. I'm trying to investigate which module seems to cause this.
This isn't actually a platform difference, but was a result of an installed library.
I filed the issue upstream https://github.com/stuaxo/vext/issues/63
Related
System: macOS Mojave 10.14.6
Python3: Python 3.7.4
My emacs config ( according to https://github.com/hlissner/doom-emacs/issues/212 );
(setq python-shell-interpreter "/usr/local/bin/python3" flycheck-python-pycompile-executable "/usr/local/bin/python3")
Trying to use run-python in emacs doom. Having:
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup failed, <class 'ModuleNotFoundError'>: No module named 'readline'
Warning (python): Your ‘python-shell-interpreter’ doesn’t seem to support readline, yet ‘python-shell-completion-native-enable’ was t and "python3" is not part of the ‘python-shell-completion-native-disabled-interpreters’ list. Native completions have been disabled locally.
import readline works perfectly in python3 in terminal.
Default python 2.7.10 doesn't work too (no my emacs config).
Python 2.7.10 (default, Feb 22 2019, 21:55:15)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import codecs, os;__pyfile = codecs.open('''/var/folders/y3/g447wqxd4l97rk7th2fszwb00000gn/T/pyQo4DAR''', encoding='''utf-8''');__code = __pyfile.read().encode('''utf-8''');__pyfile.close();os.remove('''/var/folders/y3/g447wqxd4l97rk7th2fszwb00000gn/T/pyQo4DAR''');exec(compile(__code, '''/var/folders/y3/g447wqxd4l97rk7th2fszwb00000gn/T/pyQo4DAR''', 'exec'));
python.el: native completion setup failed, <type 'exceptions.Exception'>: libedit based readline is known not to work,
see etc/PROBLEMS under "In Inferior Python mode, input is echoed".
>>>
How to make emacs doom run python3 right?
I have installed Twisted in my MAC.
$ python
Python 2.7.10 (default, Oct 23 2015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import twisted
>>> twisted.__version__
'13.1.0'
>>> import OpenSSL
>>> import twisted.internet.ssl
>>> twisted.internet.ssl.SSL
<module 'OpenSSL.SSL' from '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/SSL.so'>
>>>
I have a test program named as test.tac
How can I run that in MAC? Can i run that as python script?
p.s: Im totally new to python
If that's a Python Script than yes, you can run it on your MAC.
Also check the Twisted Documentation Page ?
http://twistedmatrix.com/documents/current/core/howto/index.html
Here's Python 2.7.6 on my Ubuntu laptop:
(myenv)$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import enum
>>> class Fruit(enum.Enum):
... apple=1
... orange=2
...
>>> Fruit.apple
<Fruit.apple: 1>
>>> type(Fruit.apple)
<enum 'Fruit'>
and here's it on Heroku (also 2.7.6):
~ $ python
Python 2.7.6 (default, Jul 15 2014, 15:38:10)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import enum
>>> class Fruit(enum.Enum):
... apple=1
... orange=2
...
>>> Fruit.apple
1
>>> type(Fruit.apple)
<type 'int'>
EDIT: My requirements.txt file contains this line:
enum==0.4.4
This is legitimately causing issues as my production version exhibits bugs the local version does not!
Looks like your ubuntu version is the enum34 backport, while the heroku version is the older enum package.
If I read your question correctly and the version with enum34 is working properly, change your requirements file to use it instead.
Check the versions of enum library. In your env there is probably older and deprecated version. Anyway field inside enum class must be of its declared type, which in your case is int.
... apple=1
... orange=2
and type of
fruit = Fruit
would be Fruit
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import enum
>>> enum.__version__
'0.4.4'
Try checking enum.__version__.
I've successfully compiled the caffe library and the python module.
I can do this:
Jamess-Air:~ james$ python2 -V
Python 2.7.10
Jamess-Air:~ james$ python2
Python 2.7.10 (default, Jul 13 2015, 12:05:58)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>>
But, bizarrely, this fails:
Jamess-Air:~ james$ python2.7 -V
Python 2.7.10
Jamess-Air:~ james$ python2.7
Python 2.7.10 (default, Jun 19 2015, 15:39:31)
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
Segmentation fault: 11
Jamess-Air:~ james$
I cannot understand this at all! Whenever I try to run using iPython notebook I get the same crash.
Any ideas as to what may be causing this, and how I might fix it, or at least get iPython Notebook to use the different python version so I can run this thing?
Thanks!
I have installed numpy and opencv using macports as per these instructions, but when I try import cv or import cv2 I just get the segfault and I have no idea why.
Any suggestions?
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
Segmentation fault: 11
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Segmentation fault: 11
Sorry there are so few details, but this is a new computer and I installed macports on it just for this, and these are the only things I've installed with macports, so I have no idea why this isn't working.
Edit: Now I'm More Confused.
Looking through the crash report I found this:
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
So, as a shot in the dark, I ran python as super user:
$ sudo python
Python 2.7.9 (default, Dec 13 2014, 15:13:49)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>>
As super user, everything appears to run fine. How is this possible?
If you look closely to the info message of your python command, you will see the difference.
From the buggy one:
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Segmentation fault: 11
From the working one:
$ sudo python
Python 2.7.9 (default, Dec 13 2014, 15:13:49)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>>
You have two different versions of Python on your machine which might explain the behaviors you got.
After hitting this problem on OSX 10.11 and trawling through several cases of this problem in various contexts, I realized that this problem happens due to following independent reasons mostly:
conflicting python versions (more than one pythons); solution - uninstall one of them, get the one thats compatible with opencv ("Segmentation fault" during "import cv" on Mac OS)
opencv version issue; solution - get the right version for you Python opencv feature detector causes segmentation fault
issue with your numpy version; solution - uninstall and install numpy again (OpenCV - cannot find module cv2)
I tried all 3 but number 3 solved my issue.
Using
cv2.ocl.setUseOpenCL(False)
at the beginning of the code solved the problem for me.
For me the solution was simply
sudo apt install python3-opencv
and then install pip opencv package
sudo pip3 install opencv-python
or
sudo pip install opencv-python
Note: This was because I have launched a new Aws instance.
I encountered the similar problem.
➜ ~ ✗ python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 13:19:00)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
[1] 41233 segmentation fault python
But if I import numpy first, the problem will go away.
➜ ~ ✗ python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 13:19:00)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> import cv2
>>>