PyCharm does not import Scapy module - python

I am trying and failing to import scapy into python, which I have now been playing with for hours and all the google hits I get seem to make sense but when I try them - it fails.
first off I am using python3 and have that nicely in pycharm:
Correct Interpreter
I have also installed the package using pip3:
pip3 install scapy-python3
this appears in PyCharm as you can see in the picture. So I am now on a par with the other guides I found.
So finally I try:
from scapy import *
and for good measure
from scapy.all import *
which is for Python2 and 3k from what I read.
Could someone give me a hand, I don't know where to go next.
Gareth

Scapy-python3 is a different and outdated project.
The correct way to install scapy on python 3 is
pip3 install scapy
Or
python3 -m pip install scapy

In some cases it is better to install scapy package for python2, too; by following command:
pip install scapy
try this.

Related

Python Libraries installing to Python 2.7 by default

I recently shifted to a Macbook. I installed Python 3.8 and installed Pyperclip using pip install pyperclip in the terminal, which was successful. When I tried to import it in IDLE shell, I get the error
ModuleNotFoundError: No module named 'pyperclip'.
On looking around I found that pyperclip has been installed in-
/Users/aamodpant/Library/Python/2.7/lib/python/site-packages/pyperclip
I did not install Python 2.7 but it must be required for macOS, so I don't want to delete it. How do I change the "default" version of Python for installing new libraries?
Use :
python3 -m pip install pyperclip
This will install the package for python3.
You can reinstall or upgrade pyperclip using sudo:
pip3 install -U pyperclip
Also, run your script using python3 instead of just python:
python3 script.py
The best is to use alias, as this answer describes changing default Python version in Mac can cause multiple issues.
alias python=python3
alias pip=pip3
The answer you are probably looking for is You should not change this.
Otherwise, you may like to set Python 3 as default, there are many ways to do it. But do it with caution as the guides suggest below.
The official documentation: Using Python on a Macintosh, some well described very good guides: The right and wrong way to set Python 3 as default on a Mac, Installing Python 3 on Mac OS X.

Can not import PySerial even though it's installed

I'm trying to import PySerial import serial, but i get a ModuleNotFoundError: No module named 'serial'. I installed PySerial via conda install pyserial and I also tried with pip install pyserial in both cases I get the same error, but if execute conda list or pip list pyserial appears in the list. I'm using VS Code on Windows and unistalled and reinstalled Anconda, VS Code and PySerial serveral times. I checked also, that there is not the serial package.
Can anybody tell me why I can not import serial?
Edit:
I also tried conda install -c conda-forge pyserial once...
Probably you are not running the python version you think you are.
Find full path of the Python interpreter?
try:
import sys
print(sys.executable)
And see if it matches what you expect.
If you don't know what to expect, it's more likely you aren't running the right pip. In that case you could make sure to run the right pip like this:
python -m pip install pyserial
Which pip is with which python?

Import error in Python 3.6 with sudo?

I have written a program that uses Scapy. Python is able to import the scapy module perfectly but using sniff function of scapy requires running the program as administrator.
However, running the program as sudo python3 <program_name> produces an import error, why is it so?
Here is the import line : import scapy.all as scapy
As using python3, I would recommend
sudo python3 -m pip install scapy
Of course pyenv works too I'd you're familiar with it.
You can fix it with:
$ sudo pip install scapy
And then try again.
I would recommend using virtualenv to run your program though. Instead of installing package after package in your main environment.

No module named 'ffnet' in Python

I try a python code for signature recognition, and there is an import ffnet module (from ffnet import mlgraph, ffnet), but I got an error when I run it.
The error is:
ModuleNotFoundError: No module named 'ffnet'
I have install the module, but still got that error
Help me to fix this :)
You need to make sure that it is correctly installed. The error message means directly "You haven't installed it properly".
Depending on what Python version you're using, you should have a package manager called pip that takes charge of installing and uninstalling modules. Try:
pip2 install ffnet if you have Python 2.
pip3 install ffnet if you have Python 3.
Alternatively, you may have installed Python using Anaconda. In this case, use conda install ffnet. In all cases, run the proposed commands in a terminal.
However, it would be quite useful to have more details about your problem (what OS do you have, how and where did you install Python, what version do you have).
There is great chance that the pip (i suppose you use pip for installation, the idea is identical) you use to install ffnet is not correspond to the python you are using. Maybe a virtualenv is running, or you using python 2 but ffnet is installed with pip3
My suggestion:
- Run which pip. Run which python. Compare the results if anything seem wrong (python2 pip3 for example). Try to run python2 and pip2 instead of python and pip
- If the above suggestion doesn't work, you should try to recheck your PATH: Find the pip correspond to your current python (usually within the same dir) and export PATH=/path/to/THAT/pip/:$PATH
- If the problem still persist, I suppose your pip file's first line (for specifying its corresponding python path) has been modified without your awareness. You will have to manually edit it to something like #!/usr/bin/python3
Hope this help!

No module named 'websocket'

I'm a fairly new to Python and I am trying to enter the following code:
from websocket import create_connection as cc
import json, time
I want to look at BTC and LTC stocks in a live feed type-fashion but I keep getting this error:
ModuleNotFoundError: No module named 'websocket'
I've been looking around and it seems that a common solution is:
pip install websocket
that just didn't connect with me. Most sites say install this and just have the above code but I have no idea where to install it or what to do with it.
First, you need to install pip if you don't have it. Type pip in your terminal or cmd to see if it is installed. Or else, install it first by downloading get-pip.py and executing it.
Then you do pip install websocket, which will install the module for you.
If the websocket and websocket-client doesn't work, try:
pip install websocket_client
It works for me.
Worked on my machine using
pip install "websockets==8.1"
you can also try
pip install websocket-client
There seem to be 2 packages in python 3.7: websocket, and websockets. In my case, I tried to install the former but it had to be the latter. Wasted half an hour of my life on that. People who get here might be in the same bag.
For me, nothing worked except Pycharm editor showed a suggestion 'install websocket' which worked(in the import line).
Try with pip install websockets that's work for me!
If you are using pip, as mentioned it is pip install websockets
However, if you are using conda,
use: conda install -c conda-forge websockets

Categories

Resources