I am using Splunk 8+ and Python 3.6. I am trying to run this https://github.com/0x616c6578/TA-geoip2 plugin.
I get this error message when I look into search.log and try to run the Python command in the log by itself:
C:\Users\strozllc>"C:\Program Files\Splunk\bin\Python3.exe" "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\geoip-command.py
Traceback (most recent call last):
File "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\geoip-command.py", line 8, in <module>
from splunklib.searchcommands import \
File "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\..\lib\splunklib\searchcommands\__init__.py", line 145, in <module>
from .environment import *
File "C:\Program Files\Splunk\etc\apps\TA-geoip2-main\bin\..\lib\splunklib\searchcommands\environment.py", line 20, in <module>
from logging.config import fileConfig
File "C:\Program Files\Splunk\Python-3.7\lib\logging\config.py", line 30, in <module>
import logging.handlers
File "C:\Program Files\Splunk\Python-3.7\lib\logging\handlers.py", line 26, in <module>
import logging, socket, os, pickle, struct, time, re
File "C:\Program Files\Splunk\Python-3.7\lib\socket.py", line 49, in <module>
import _socket
ImportError: Module use of python27.dll conflicts with this version of Python
n.
Huh? I looked at line 8 in geocommand.py and it is from
splunklib.searchcommands import \
dispatch, StreamingCommand, Configuration, Option, validators
I look it C:\Program Files\Splunk\bin, and there is indeed a python27.dll. But how is it getting called?
This is a case of Python 3 trying to run Python 2 code. The latest versions of Splunk (you didn't say which one you're using) only support Python 3 so an error will be thrown when an outdated library file is encountered.
I'd suggest filing an issue on GitHub, but the app appears to be abandonware since it hasn't been touched in a year despite having 4 issues.
Consider forking the code and updating it yourself.
Related
I try to import discord in python 3.5, but I get the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\Python35-32\lib\site-packages\discord\__init__.py", line 20, in <module>
from .client import Client, AppInfo, ChannelPermissions
File "C:\Python\Python35-32\lib\site- packages\discord\client.py", line 42, in <module>
from .voice_client import VoiceClient
File "C:\Python\Python35-32\lib\site- packages\discord\voice_client.py", line 65, in <module>
from .gateway import *
File "C:\Python\Python35-32\lib\site- packages\discord\gateway.py", line 31, in <module>
import aiohttp
File "C:\Python\Python35-32\lib\site- packages\aiohttp\__init__.py", line 10, in <module>
from .protocol import * # noqa
File "C:\Python\Python35-32\lib\site- packages\aiohttp\protocol.py", line 11, in <module>
from wsgiref.handlers import format_date_time
ImportError: cannot import name 'format_date_time'
I installed discord inside Python35-32\Scripts using pip install discord. Additionally, I installed asyncio using pip install asyncio in the same directory.
The error pops up in my command prompt, when I type in "python", wait for it to open, and then type "import discord". I'm saying that just to be clear that it's not a "I have a file named XXX.py which clashes with something from the discord library" type of error.
Based on the comments you have added and the line
File "C:\Python\Python35-32\lib\site- packages\aiohttp\protocol.py", line 11, in <module>
from wsgiref.handlers import format_date_time
ImportError: cannot import name 'format_date_time'
The problem seems to be that 'format_date_time' could not be imported from the built in library wsgiref. Turns out that the file ...\Python35-32\lib\wsgiref\handlers.py was completely empty indicating that something corrupted your python installation.
Two possible solutions:
Reinstall your python completely which also has the benefit of solving other potential corruptions that you might not have noticed yet (Note that the underlying cause for this corruption remains unknown)
Go into the Cython git and copy the contents of the handlers.py into the local file. This is a very specific solution however and you should be aware that other parts of your python installation might also be corrupt.
Maybe you wanted to pip install discord.py instead of discord?
UPDATE: if I change the name of the select module (in which the import error occurs) to select1, the problem goes away! WHAT the?
First off: everything works fine when I try to import my package from the command line, or run pytest in the project directory.
But in PyCharm I'm getting the "attempted relative import beyond top-level package" problem when I try to run my tests, and ONLY while in PyCharm. I can't figure out why.
I have even deleted and re-cloned the repository and the problem still occurs.
Here is the link to the problem branch.
And here is the tb:
Testing started at 4:02 PM ...
C:\Users\ricky\AppData\Local\Programs\Python\Python37\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pycharm\_jb_pytest_runner.py" --path C:/Users/ricky/PycharmProjects/candejar/tests
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.2\helpers\pycharm\_jb_pytest_runner.py", line 10, in <module>
from pkg_resources import iter_entry_points
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\site-packages\pkg_resources\__init__.py", line 36, in <module>
import email.parser
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\email\utils.py", line 29, in <module>
import socket
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\socket.py", line 52, in <module>
import os, sys, io, selectors
File "C:\Users\ricky\AppData\Local\Programs\Python\Python37\lib\selectors.py", line 12, in <module>
import select
File "C:\Users\ricky\PycharmProjects\candejar\candejar\select.py", line 24, in <module>
from . import exc
ImportError: attempted relative import with no known parent package
Process finished with exit code 1
I'm sure there is something simple going on here but I just can't figure it out. NOTE: I'm using Python 3.7 RC 1.
The sys.path in pycharm and the command line come out to be the same, except pycharm also includes the pycharm project main package directory (which for some reason appears twice).
I was able to solve this by deleting the .idea directory from the cloned repository and re-opening PyCharm. I still don't know what was wrong, but it is fixed now. Very weird.
UPDATE: it has something to do with the following line in the project .iml file in the .idea folder:
<sourceFolder url="file://$MODULE_DIR$/candejar" isTestSource="false" />
Removing that xml code solves the issue. But I do not know why, and I don't know how it got there in the first place (I do not recall messing around with any of my settings prior to this error).
This question already has answers here:
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 6 years ago.
I have a problem, when try to use requests lib
import requests
r = requests.get('http://www.python.org/')
print(r)
After that, I got the following error
Traceback (most recent call last):
File "C:/Users/admin/Documents/alex/test.py", line 3, in <module>
import requests
File "C:\Program Files\python3\lib\site-packages\requests\__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "C:\Program Files\python3\lib\site-packages\requests\packages\__init__.py", line 27, in <module>
from . import urllib3
File "C:\Program Files\python3\lib\site-packages\requests\packages\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Program Files\python3\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 35, in <module>
from .connection import (
File "C:\Program Files\python3\lib\site-packages\requests\packages\urllib3\connection.py", line 44, in <module>
from .util.ssl_ import (
File "C:\Program Files\python3\lib\site-packages\requests\packages\urllib3\util\__init__.py", line 20, in <module>
from .retry import Retry
File "C:\Program Files\python3\lib\site-packages\requests\packages\urllib3\util\retry.py", line 15, in <module>
log = logging.getLogger(__name__)
AttributeError: module 'logging' has no attribute 'getLogger'
I do not understand why is it at all. Please, help me.
Your problem is one of the following
Your installation of Python is terribly broken
When C:\Program Files\python3\lib\site-packages\requests\packages\urllib3\util\retry.py tries to import logging it imports wrong file. This may happen because
There is file called logging.py in the directory you are running your test.py from. In this case, you will need to rename it so that logging from Python library is imported, not yours.
There is file called logging.py in one of directories from Python Path and it gets found before the logging.py the module actually needs
To check what logging gets imported, write the following simple program
import logging
import os.path
print os.path.abspath(logging.__file__)
Whatever is printed is path to your logging file. If it is not along the line of ...\Python\\Python36\\lib\\logging\\__init__.py, the wrong file is imported and you got to replace/rename it
I installed pygui and pywin32 for my 64-bit python 2.7 (I installed 64-bit for those too) and when I try to use pygui, which uses pywin32, python gives me this error.
I'm sure that other people might have similar problems.
Traceback (most recent call last):
File "C:\Users\MY_USERNAME_HERE\Dropbox\Python Programs\BlobEdit\BlobEdit.py", line 16, in <module>
from GUI import Application, ScrollableView, Document, Window, Cursor, rgb
File "C:\Program Files\python2.7.2\lib\site-packages\GUI\__init__.py", line 94, in <module>
import GUI.Application
File "C:\Program Files\python2.7.2\lib\site-packages\GUI\Application.py", line 11, in <module>
from GUI.GApplications import Application as GApplication
File "C:\Program Files\python2.7.2\lib\site-packages\GUI\GApplications.py", line 14, in <module>
from GUI.Printing import PageSetup, present_page_setup_dialog
File "C:\Program Files\python2.7.2\lib\site-packages\GUI\Printing.py", line 11, in <module>
from GUI import Canvas
File "C:\Program Files\python2.7.2\lib\site-packages\GUI\Canvas.py", line 15, in <module>
from GUI.StdFonts import application_font
File "C:\Program Files\python2.7.2\lib\site-packages\GUI\StdFonts.py", line 9, in <module>
from GUI import Font
File "C:\Program Files\python2.7.2\lib\site-packages\GUI\Font.py", line 56, in <module>
pywin32_info = api.GetFileVersionInfo(api.__file__, '\\')
error: (1813, 'GetFileVersionInfo:GetFileVersionInfoSize', 'The specified resource type cannot be found in the image file.')
Apparently, PyWin32 can't find it's version or something. I wonder why.
I've had this issue, which led me to this question.
I'm using python 3.3 and had already installed pywin32-218, so my solution was this hack in Font.py:
#pywin32_info = api.GetFileVersionInfo(api.__file__, '\\')
pywin32_build = 218 # pywin32_info['FileVersionLS'] >> 16
I've had this issue too, easy solution: install the minimum required pywin32 version 213. Somewhere there a version check happening in pywin32 on some file. Perhaps some day i will dig into it further and post a more detailed post and/or file a bug
After installing Lion, Aptana has stopped working -- I can no longer run any Python code, despite me failing to find any other problems with Python my system. I've tried restoring defaults in Aptana, re-installing and looking for any missing references in Aptana to python components.
Running a simple "hello world" .py script generates a console message:
Traceback (most recent call last):
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/runfiles.py", line 159, in <module>
main()
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/runfiles.py", line 25, in main
import pydev_runfiles
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_runfiles.py", line 5, in <module>
import pydev_runfiles_unittest
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_runfiles_unittest.py", line 6, in <module>
import pydev_runfiles_xml_rpc
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_runfiles_xml_rpc.py", line 1, in <module>
from pydev_imports import xmlrpclib
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/pydev_imports.py", line 14, in <module>
from _pydev_SimpleXMLRPCServer import SimpleXMLRPCServer
File "/Applications/Aptana Studio 3/plugins/org.python.pydev.debug_2.2.1.2011073123/pysrc/_pydev_SimpleXMLRPCServer.py", line 116, in <module>
import BaseHTTPServer
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py", line 81, in <module>
import mimetools
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/mimetools.py", line 6, in <module>
import tempfile
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/tempfile.py", line 34, in <module>
from random import Random as _Random
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/random.py", line 45, in <module>
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: dlopen(/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so, 2): Symbol not found: __PyLong_AsScaledDouble
Referenced from: /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so
Expected in: flat namespace
in /System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload/math.so
Have you tried removing your interpreter and adding it again (that way PyDev would update your PYTHONPATH?
It seems like the problem is that the math.so is not compatible with the latest changes in Lion (so, maybe in the update for Lion it got to 2.7 and you're still with 2.6 in the PYTHONPATH configure in Eclipse?)
For me, a better choice would be using an interpreter downloaded from python.org (where you have more control and don't need to rely on what Mac gives you) and configure the python from python.org.
See: http://pydev.org/manual_101_interpreter.html