Importing python project from github - python

Im trying to download this project in python from github
and import it to eclipse ubuntu.
The interpreter of python is 3 and I noticed that after the git clone and running the setup.py, the output is in folder python 2.7 instead of python 3
And when I try to import scapy_http.http I get an exeption (probably the interpreter looking for it inside python 2.7 folder).
When I try to replace the interpreter to python 2.7 I get other exeption on import scapy.all
the import scapy suppose to come before import scapy_http
I installed scapy for python 3: pip3 install scapy-python3
So how can I import the scapy-http project to my eclipse project given the interpreter is python 3?
Thanks.

It should be ok if you did pip3 install scary-python3. It's a bit hard to tell exactly what's going on (please provide error messages, etc.) but I would suggest you try:
sudo python3 setup.py install
If you haven't already. The problem might be that you left off the 3 and thus it was stored in python 2 libraries.

Related

Unable to fully package my Python script with all the modules and dependencies it needs for Linux

I have a Python 2.7 script that uses BeautifulSoup4 and requests modules.
The issue is, that I need to deploy this script on a machine to which we can not directly install any new modules/libaries via pip install or anything else.
We can copy this script and any files it needs to run to that machine, but we can not directly install any modules.
I have tried PyInstaller, PEX and Nuitka to create an executable file or a bundle (in any format, for example .zip) so that we can copy the entire file or bundle into the machine and run the python script from there, without the need to do pip install or installing the modules manually via Wheel file. All without success.
Environment details:
Target machine on which the script needs to run: RHEL-based Linux OS with Python 2.7.
My development machine: Windows 10 but I also have access to Fedora Linux machine both with Python 3 and Python 2.7.
The import section of my script looks like this:
from __future__ import with_statement
from __future__ import absolute_import
import requests
import re
from bs4 import BeautifulSoup
from io import open
Can someone, please, help me out here?
We have the script ready to be deployed, but we are not able to run it in our target machine because of the missing modules/libraries.
Thank you very much
EDIT:
Mentioning this since it may not be clear at first - we do not have the issue with a network connection or anything of this gender. We were prohibited to use pip install or a manual method of installing a module. Therefore, we can only bundle the modules directly with the script or something so that would not need to directly install the modules on the target machine itself.

ANTLR3 python runtime not detected

I want to use fstpso package in python which needs ANTLR3 python runtime.
I downloaded antlr_python_runtime-3.1.3.tar.gz from http://www.antlr3.org/download/Python/ and ran the command sudo python setup.py install. The output of the command was
Installed /path/to/python/packages/antlr_python_runtime-3.1.3-py2.7.egg
But after this when I try to import fstpso module in python, it throws the error
The ANTLR3 python runtime was not detected; pyfuzzy cannot import FST-PSO's FLC files
I am using python 2.7.12 on linux.
Is there something I did wrong? Or I have to update any PATH in the environment?
Thanks for your help!!
I'm fst-pso main developer. In the last days I reimplemented the Sugeno reasoner from scratch, to finally remove the pufuzzy/ANTL3 dependency. I just uploaded the new package on PyPI.
Now you can pip install the new version of fst-pso (v 1.4.0); please let me know if that works correctly.

Python Import problems for installed module

I've spent 2 hours trying everything to get this python module working. It's a security module called Kitty Fuzzer.
I've installed it "pip install kittyfuzzer" as well as tried "pip2 install kittyfuzzer". It shows as installed when doing python -c "import kitty".
However when I run a script that imports a submodule (like the script below), it says that submodule is not found. I've checked the source and API, and it's definately there (e.g. https://github.com/cisco-sas/kitty/blob/master/kitty/fuzzers/client.py).
Any tips for getting the import to work?
I've tried running it in python2 and python3
Test script:
https://github.com/cisco-sas/kitty/blob/master/examples/01_file_generator/runner.py
thanks!
Kittyfuzzer is supporting only Python 2.
You can validate this by open kittyfuzzer's setup.py:
# python 3 - install only the remote package
if sys.version_info >= (3,):
setup(
name='kittyfuzzer-remote',
...
# python 2 - install full kitty framework
else:
setup(
name='kittyfuzzer',
...
I suppose you installed it for Python 3 only.
What you should to do is to run following command "pip install kittyfuzzer" directly from folder with Python 2 pip installer(for example: C:\Python2\Scripts). This will install kittyfuzzer for Python 2. Now you can run your code with Python 2.

Getting the correct version of Pmw to install

Problem:
I'd like to install Pmw 2.0.0 (project page here) so that I can use it with tkinter in python3. The setup script from the package detects which version of python you're using and installs the version that is appropriate for your system (Ubuntu 15 in my case). I can't find any references to switches to make it install the 2.0.0 instead of 1.3.3(the Python 2.7 version), nor have I been able to get the script to install to the python3 libraries.
What I've done so far:
I've changed the python version detector in the setup script from
if sys.version_info[0]<3:
version='2.0.0' # really '1.3.3'
packages=['Pmw', 'Pmw.Pmw_1_3_3', 'Pmw.Pmw_1_3_3.lib',]
to
if sys.version_info[0]<2:
version='2.0.0' # really '1.3.3'
packages=['Pmw', 'Pmw.Pmw_1_3_3', 'Pmw.Pmw_1_3_3.lib',]
to attempt to force the installer to default to the python3 version, which it does, but it installs them in the python2.7 libraries (/usr/local/lib/python2.7/distpackages).
What I want to do:
I'm looking for a way to force the installer to put the 3.4-compatible package into the python3 libraries. If that means getting it to install both packages in their respective correct directories, that's fine, too. I'm stumped about what to try next.
Answered by RazZiel on AskUbuntu:
Link here.
Instead of using the command sudo python setup.py build and then sudo python setup.py install, I should have been using python3 to execute the setup script. I've managed to outthink myself pretty badly on this one.

How to type into cmd using python 2.7

I have a program here that I would like to convert to 2.7. This code works well in Python 3.x, however, for my needs it must be 2.7. Could someone 'convert' this to python 2.7 for me? I have heard of a 3to2.py tool but I do know how to get/use it. Anyway, here is the code I have for 3.3.
def compiler(program):
import os, win32com.client, time
os.startfile("C:\\Windows\\System32\\cmd.exe")
time.sleep(2)
shell = win32com.client.Dispatch("WScript.Shell")
shell.AppActivate('C:\\Windows\\System32\\cmd.exe')
setup(program)
shell.SendKeys("py MyCompiling.py.setup("+program+") py2exe\n")
def setup(program):
from distutils.core import setup
import py2exe
setup(console=[program + ".py"])
compiler('test1')
EDIT: When I try to run I get
ImportError: No module named win32com.client
Do I have to install this module seperately? If so, could someone please post the link.
Yes, you must install the library separately. In fact, if you visit the SourceForge page, you will see that there is an entirely different binary available for 2.7. You will want pywin32-218.win32-py2.7.exe if you are using 32-bit Python or pywin32-218.win-amd64-py2.7.exe if you are using 64-bit Python.
You can install it via the GUI interface (which comes up when you try to execute the file), or you can call easy_install on it (if you have setuptools or distribute installed) at the command line:
C:\> C:\Python27\Scripts\easy_install pywin32-218.win32-py2.7.exe
Using easy_install is the only way if you want to install the library in a virtual environment created with virutalenv.

Categories