unable to get kml_filter.py working

Talk about whatever

8 posts • Page 1 of 1
On a different laptop i had this working 2 or 3 years ago. Now i am just baffled, in spite of the notes i took back then.

I am trying to run kml_filter.py out of my Downloads directory. (When i tried running it out of an "environment" i got other error messages which i also don't understand).

This is what i get just trying to run it with the -h option:

sudo python kml_filter.py -h
[sudo] password for sarah:
Traceback (most recent call last):
File "kml_filter.py", line 43, in <module>
from fastkml import kml
ImportError: No module named fastkml

I installed fastkml. I just don't know how to make kml_filter.py use it.

Appreciate any help. My war-driving uploads to Wigle, i think i specified you can use or sell the info. I am a contributor.
Without kml_filter.py, Google Earth just shows too much irrelevant stuff. I need to get this going.

When i try the following i get the same message:

sudo python kml_filter.py -o 23apr21 *.kml
Traceback (most recent call last):
File "kml_filter.py", line 43, in <module>
from fastkml import kml
ImportError: No module named fastkml

Thanks for any help.
perhaps

viewtopic.php?f=5&t=2543&p=9627&hilit=pip#p9627

will help?

python like having a virtual environment to install all the libraries so they don't conflict at a system level (and so you don't need to run things w/ sudo, which can be scary)
perhaps

viewtopic.php?f=5&t=2543&p=9627&hilit=pip#p9627

will help?

python like having a virtual environment to install all the libraries so they don't conflict at a system level (and so you don't need to run things w/ sudo, which can be scary)
----------------------------------

OK, from that link i see that you said:


Basic steps:
1. create a directory, enter that directory with the terminal prompt of your choice. Then, create a virtual environment:

virtualenv wigleKmlTest


So i did that, and the output was:

virtualenv wigleKmlTest
created virtual environment CPython3.9.2.final.0-64 in 2710ms
creator CPython3Posix(dest=/home/sarah/wigleKmlTest, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/sarah/.local/share/virtualenv)
added seed packages: pip==20.3.4, pkg_resources==0.0.0, setuptools==44.1.1, wheel==0.34.2
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator






Next step, you wrote:

source ./wigleKmlTest/bin/activate
(ymmv on slash direction and "source" command based on OS)

and i got:

─$ source ./wigleKmlTest/bin/activate

┌──(wigleKmlTest)(xxxx@yyyy)-[~]
└─$
That's good.




Then your next step was:

2. still in that directory, install fastkml into that environment

pip install git+git://github.com/cleder/fastkml

And i got:

┌──(wigleKmlTest)(xxxx㉿yyyy)-[~]
└─$ pip install git+git://github.com/cleder/fastkml 1 ⨯
Collecting git+git://github.com/cleder/fastkml
Cloning git://github.com/cleder/fastkml to /tmp/pip-req-build-q04oprfo
Running command git clone -q git://github.com/cleder/fastkml /tmp/pip-req-build-q04oprfo
Collecting pygeoif
Using cached pygeoif-0.7-py3-none-any.whl
Collecting python-dateutil
Using cached python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
Collecting six>=1.5
Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Building wheels for collected packages: fastkml
Building wheel for fastkml (setup.py) ... done
Created wheel for fastkml: filename=fastkml-0.11-py3-none-any.whl size=62616 sha256=44abc599b67204bdb0c4b770a0b0850066a6d67347cd93a07023bf0fece05051
Stored in directory: /tmp/pip-ephem-wheel-cache-ssmpzz2d/wheels/f2/02/72/bc05113e037e6f139473b6726ac742f2fcdb4a6b6c8dd92173
Successfully built fastkml
Installing collected packages: six, python-dateutil, pygeoif, fastkml
Successfully installed fastkml-0.11 pygeoif-0.7 python-dateutil-2.8.1 six-1.15.0





Then you wrote:

3. download the script into that directory. Run it with the "-h" option for help on usage (again, unix slashes presented for illustration):
python ./kml_filter.py -h

I put kml_filter.py in both "(wigleKmlTest)(xxxx@yyyy)" and in "(wigleKmlTest)(xxxx@yyyy)-[~/wigleKmlTest]"
I did that, and got:


┌──(wigleKmlTest)(xxxx㉿yyyy)-[~]
└─$ python ./kml_filter.py -h 127 ⨯
File "/home/xxxx/./kml_filter.py", line 72
print "Invalid name: %s"%filename
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Invalid name: %s"%filename)?



So then i tried:

┌──(wigleKmlTest)(xxxx㉿yyyy)-[~]
└─$ cd wigleKmlTest

┌──(wigleKmlTest)(xxxx㉿yyyy)-[~/wigleKmlTest]
└─$ ls
bin kml_filter.py lib pyvenv.cfg

┌──(wigleKmlTest)(xxxx㉿yyyy)-[~/wigleKmlTest]
└─$ python ./kml_filter.py -h
File "/home/xxxx/wigleKmlTest/./kml_filter.py", line 72
print "Invalid name: %s"%filename
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Invalid name: %s"%filename)?









This is under Kali latest download, when i do "hostnamectl" it says "Kernel: Linux 5.10.0-kali7-amd64."
I then checked on another laptop running Parrot, which (if i recall) had kml_filter.py running OK, and it also gave error
messages (not these same error messages; different error messages.)

So i don't know what to do next. Thanks for any help.
So, in my other posts: (1) haven't been able to get it going on my Kali/Win7 laptop, (2) couldn't get it working on a Parrot Home laptop, and now
(3) I got kml_filter.py to run on a Dell using Ubuntu 18.04, so at least i can process my kml files and use a usb stick to move the files (until i set up
my home ethernet network).

In fact, on the Ubuntu 18.04, i am running kml_filter.py out of my Downloads directory, without having to create an "environment." Like my other
attempts, with or without an environment, i did:

sudo pip install fastkml
sudo pip install -r requirements.txt

where requirements.txt has the following content:

# Base package requirements
pygeoif
python-dateutil

# Testing Requirements
pytest
pep8
coveralls
tox>=1.8

# Documentation Requirements
Sphinx
sphinx-rtd-theme

---------------------------------------


I don't know if all that is needed, but i did it anyway.

This is great for now, but it would be great if i could get kml_filter.py to run under my Kali, and also to understand what the problems are
that are stopping me from doing that.

Best regards, and thanks for any comments you have...
Glad you got it working, but we strongly recommend not installing dependencies or running the script as sudo.
The script lists its dependencies at the top of the file, and a virtual environment will help you partition those dependencies as well as protect yourself.
it's possible that this is a python 2.x v. 3.x problem - perhaps try pip3 and python3 ?
I've taken a quick pass and done some cleanups that will keep the script working in python 2.x and 3.x, as well as run it through a style checker. You can download the latest from https://wigle.net/tools

To clarify the instructions:

1. choose a directory - we'll call it the base directory to install kml_filter.py
2. on the commandline from within that directory, create the virtual environment - use the version of python you intend to use to run the script to create and activate the environment.
3. use the version of pip corresponding to the version of python you intent to use to run the script to install the fastkml library in that virtual environment.
4. run the script.

Making sure you're using the matching version of the toolchain is vital. Many OSes have python 2 and 3 installed at the moment - if you use

Code: Select all

python3
you must also use

Code: Select all

pip3
.
Thanks Arkasha... am taking notes, and will work on this tomorrow.

lord.tywin lol

8 posts • Page 1 of 1

Return to “General Grabbag”

Who is online

Users browsing this forum: No registered users and 14 guests