though that can be useful if one does it in the other direction either way, python finds the absolute path of the regular file, and the rest of this analysis applies to wherever that file is: inside the module, get the module's logging outside the module, get the system logging. Note: it's not enough to create a symlink. Hopefully this helps someone get past this error! It confounded me for a bit, and this was the solution that worked for my purposes. bottom line: if there's a logging module anywhere near where the file you're trying to run code from lives, there's a good chance python is trying to import that version of logging instead of the usual system one.įor module owners, I'd suggest considering renaming the module's logging to something else, to avoid creating this problem for your users.įor regular users of a thing, just pay attention to where you're calling your code from (including where the file physically sits on the filesystem, relative to various modules that might get imported). This would presumably also apply to various other ways of invoking things than just shebang scripts (e.g. Or vice-versa: a working script in ~ will break if I copy it to pythonX.Y/site-packages/whatever. I copy it to my home directory, and run it as ~/test), then it works. If, however, I copy the exact same file out of the pythonX.Y/site-packages/whatever directory, and try running it from that somewhere else (e.g. test - again, from within the whatever directory - or perhaps even elsewhere within the same site-packages, I'm not sure), I'll get the error you described. The self-serving bias is the tendency to attribute our successes to internal causes and our failures to. We can distort the attributions we make about our behavior in order to protect our ego, enhance our self-esteem, or look good to others. there's a logging.py or logging/_init_.py somewhere within the whatever directory hierarchy), and then try to run it (via, say. The motivational biases occur when something motivates us internally to make a particular attribution. If I have a small utility called test, that's meant to be run from the command line (it starts with a " shebang" line specifying some python or other), and I put it inside the directory of a python module (let's say pythonX.Y/site-packages/whatever, for example) that in turn has a logging module within it (i.e. One possible solution for this problem (depending on the exact details) has to do with where one is running code from - and changing it. Try searching for python library path if nothing works then only one option left is to change version If the current file you are working has name logging.py change it else it will give circular import error. ![]() This type of problem occurs whenever there is circular import or any other logging module which don't have getLogger.Īlthough you said you searched for any file naming logging.py but still i think your project has filename logging.py somewhere.
0 Comments
Leave a Reply. |