how to solve "no module named networkx" Error? - ubuntu-14.04

i am trying to run a python code as pox controller using below command :
./pox.py openflow.discovery CloudNetController
but always i get this error:
could not import module : CloudNetController
please help how can i solve this error.

Is this controller?
this controller imports :
import networkx as nx
Hence you should
pip install networkx

Related

Installed PILLOW Module is not Identifying to Import in Python 3

I have installed the PILLOW module in Windows 8.1 for Python 3 using the below command.
pip install pillow
The installation was a success.
Unfortunately when I tried to import the image sub-module within it using the below statement I got an import error.
from PIL import image
Error: ImportError: cannot import name 'image' from 'PIL' (C:\Program Files\Python38\lib\site-packages\PIL_init_.py)
Although the below statement is giving me an error for the 'PIL' .
image = PIL.Image.open("Capture Image.PNG")
Error: Undefined variable: ' PIL'Python(undefined-variable)
I have tried similar posts listed below, but they didn't help me to solve the issue.
Pip install Pillow: "no module named Pillow?"
Pillow installed, but getting "no module named pillow" when importing
Python pillow module not importing properly
Could you please someone explain what I'm missing here?
Regards,
Chiranthaka
#dragon2fly Many thanks for solving the issue. Please refer the below snippet for the complete source code.
from PIL import Image
image = Image.open("Capture_image.png")
print(image.size)

Unable to install PySpark Module Error No Module Found

I'm trying to work with Microsofts Hyperspace application.
In order to make it work with Python I need to install the module called Hyperspace.
When I implement the code from hyperspace import * I get the following error:
ModuleNotFoundError: No module named 'hyperspace'
I tried the following but still no luck
from pyspark hyperspace import *
Can someone let me know what it will take to successfully install the module?
I
Thanks
The module isn't supported on Databricks

Python tabula-py cannot import name wrapper

Here is my code:
from tabula import wrapper
df = wrapper.read_pdf('singapore.pdf')
But it gives following error:
ImportError: cannot import name 'wrapper'
I tried it on ubuntu and it works fine there but on Windows I am unable to use this code, as it always gives the above error. I installed tabula by using this command:
pip3 install tabula-py
Here is how I resolved it, you need to add java path to environment variables. More details can be found here:
https://tabula-py.readthedocs.io/en/latest/getting_started.html#get-tabula-py-working-windows-10

Python3 numpy import error PyCapsule_Import could not import module "datetime"

I am trying to import numpy with python3 on MacOS mojave. I am getting this error. I don't know if it has something to do with a virtual environment or something like that.
Error:
PyCapsule_Import could not import module "datetime"
I have tried reinstalling python3 and reinstalling numpy
In my case I had this problem, because my script was called math.py, which caused module import problems. Make sure your own python files do not share name with some of common module names. After I renamed my script to something else, I could run script normally.

AttributeError: module 'networkx.algorithms.community' has no attribute 'best_partition'

well i am trying to use community detection algorithms by networkx on famous facebook snap data set.
here are my codes :
import networkx as nx
import matplotlib.pyplot as plt
from networkx.algorithms import community
from networkx.algorithms.community.centrality import girvan_newman
G_fb = nx.read_edgelist("./facebook_combined.txt",create_using = nx.Graph(), nodetype=int)
parts = community.best_partition(G_fb)
values = [parts.get(node) for node in G_fb.nodes()]
but when i'm run the cell i face with the title error which is :
AttributeError: module 'networkx.algorithms.community' has no attribute 'best_partition'
any advice ?
I think you're confusing the community module in networkx proper with the community detection in the python-louvain module which uses networkx.
If you install python-louvain, the example in its docs works for me, and generates images like
Note that you'll be importing community, not networkx.algorithms.community. That is,
import community
[.. code ..]
partition = community.best_partition(G_fb)
I faced this in CS224W
AttributeError: module 'community' has no attribute 'best_partition'
Pls change this file karate.py
replace import to
import community.community_louvain as community_louvain
then it works for me.
I had the same problem. In my case, it was solved importing the module in a different manner:
import community.community_louvain
Source
I also faced this in CS224W
but changing the karate.py or other solutions didn't work.
For me (in colab) using the new PyG installation code worked.
this code, will install the last version:
!pip install -q torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cu102.html
!pip install -q torch-sparse -f https://pytorch-geometric.com/whl/torch-1.9.0+cu102.html
!pip install -q git+https://github.com/rusty1s/pytorch_geometric.git
I had a similar issue.
In my case, it was because on the other machine the library networkx was obsolete.
With the following command, the issues was solved.
pip3 install --upgrade networkx
I naively thought that pip install community was the package I was looking for but rather I needed pip install python-louvain which is then imported as import community.
This has helped me to run the code without errors:
pip uninstall community
import community.community_louvain as cl
partition = cl.best_partition(G_fb)

Resources