Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

pythonpath - How to fix Python ModuleNotFoundError

I have installed netfilterqueue a couple of ways, cloning from GitHub and installing through pip. On python 3.7,3.8,3.9. Netfilterqueue only installed on 3.6 and 3.7 even though it took some time. After installing and testing if netfilterqueue worked in interactive mode which it did I try to run my program that has worked before doesn't. It gives me a modulenotfound error.

ModuleNotFoundError: No module named 'netfilterqueue'

I don't know what I'm doing wrong pip tells me it is installed correctly, but it just doesn't work in a program.

EDIT So I'm not using pycharm or anaconda i mostly code in VS Code. But I haven't even got that far yet. I'm just running my script in the terminal, and it can't find the module from the script. I have installed all of those dependencies and when i run that command I get

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'python-dev-is-python2' instead of 'python-dev'
build-essential is already the newest version (12.8).
libnetfilter-queue-dev is already the newest version (1.0.3-1).
python-dev-is-python2 is already the newest version (2.7.18-8).
The following packages were automatically installed and are no longer required:
  libpython3-dev libpython3.9-dev python3.9-dev
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.

Now all of a sudden the pip3 install netfilterqueue for python 3.6 is not working either. My system has python 3.9 and 2.7 installed on it, I am using pyenv to manage my python 3.6 version to try and run my script that requires netfilterqueue.

UPDATE: So I rebooted my computer and started from a new Kali live, and it worked with python 3.8.4 which came with the Kali live. I'm not sure what I did to break my installation. I had just installed it and installed KDE and latte dock and updated I think it may be due to a testing repo I added but im not sure could that be the problem?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

According to this question How do I install netfilterqueue for python3? it looks like that netfilterqueue doesn't work well with python 3.7 but works fine with 3.6, so adjust the the whole environment to be in version 3.6 however in anaconda or pycharm through project interpreter

  1. Also you need to install this according to the documentation https://pypi.org/project/NetfilterQueue/ and to the second answer in the previous question

    sudo apt-get install build-essential python-dev libnetfilter-queue-dev
    
  2. Also If you're working with anaconda jupyter note book or spider most probably the interpreter can't find where the package is installed The easiest way to fix this is to just reinstall using the --user flag. By default, Anaconda will pull in your user packages. Try pip3 install netfilterqueue --user, and then see if you can import it.

       pip3 uninstall netfilterqueue
       pip3 install netfilterqueue --user
    

Please after doing so restart your anaconda
Also sometimes the problem is with the setup tools you can try reinstalling them


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...