How to add mininet module to pycharm? - python

I'm trying to run a python code that imports mininet. I got the error
ModuleNotFoundError: No module named 'mininet.net'
I tried to add mininet from the interpreter but there are only ipmininet (which keeps fail in installing) and mininet-topology-yaml.
Any idea how to solve this issue?
How I can add mininet to pycharm?
Thanks in advance.

I solved the problem. The PyCharm Python interpreter should be python 2 not any other version.
Someone may need this answer in the future!!

I would like to correct the fact that the python 2 does not have to be used. For some reason, installing from packages only installs in the python 2 library directory and not python 3.
But when installing from source you can control this behavior.
To install mininet with python 3 directories, follow the official installation guide from source, but before running the install.sh script, prefix it with the statement PYTHON=python3. So your installation command will be PYTHON=python3 ./install.sh
Here's the line of code that checks what python version is installed

Related

Why is my python module not importing ON linux

As you can see I have imported the modules correctly using pip install. I googled a bit why the module was not imported and I realized I have to add it to PATH. I did that too but now there is a new error something about a syntax error
File "pygame/__init__.py",
self.reason = f"{exc_type.__name__}: {self.info}"
Is this because my chrome book can not run Pygame or is the problem something else?
Picture of my terminal with the error:
you need to run python3. to start python 3. Just running python starts python 2.7.
you have your installed packages in python 3.9 version while your python environment is 2.7, look for python3 executable and try with that version

"unresolved import" in Python - all other imports worked so far?

I am a bit lost. I've just recently started working with python and have been able to use other libraries, that I've imported without any issues.
Install via pip command
Restart Visual Studio Community 2019
I can use the library
Now I wanted to import the docx2pdf library. But using the same 3 steps is not working and I don't know what to do.
from docx2pdf import convert <-- gets the error "unresolved import"
Also:
after installing it via pip I get the following message in addition to the installation being a success:
WARNING: The script docx2pdf.exe is installed in 'C:\Users\user\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
I didn't get this message from other libraries.
I am using windows 10.
Thanks for the help!
In VS Code, when we use the global python environment to install the module, we can use the command "pip show docx2pdf" to check its storage location is: "\users\username\appdata\local\programs\python\python38\lib\ site-packages"
It is recommended that you reinstall the module "docx2pdf" or try to delete the previously installed "docx2pdf" folder and reinstall it.
Run:

Importing python modules works in command line but not in the python 3.8 shell

I'm having a problem with importing modules in python.
When I run my program in the command line it works perfectly fine.
However, when I try to run the same program in the python shell I am prompted with the following error:
ModuleNotFoundError: No module named 'matplotlib'
I already successfully installed matplotlib using 'python -m pip install matplotlib'.
I've read this can happen when you have two different versions of python installed; however, I don't.
I've uninstalled and reinstalled python and I still am having the same issue. I've also uninstalled and reinstalled matplotlib using pip.
I believe my problem is the module paths that python uses to search for imported modules are different between the two.
When I use the 'print(sys.path)' command in the python shell and the command line I get two different outputs.
Any help would be greatly appreciated!!!
The file different system paths between the python shell and the command line
You have two versions of python. I would recommend you to remove all pythons you have and go for anaconda https://www.anaconda.com/distribution/. It will fix your path problems and allow you to create environments with different versions of python. This is the least painful way also for future :) good luck.
I suppose, you have both of the Python versions installed on the same computer.
If that is so, then my answer would be to go inside both Python script folders and install matplotlib on both of them.
I have also faced that issue. My path includes pip of Python 3.7.1 and whenevwer I try to import modules on Python 3.4. It throws an error!
Maybe, you could add both of the Pythons to the path.
I encountered this same problem – python -c "import sklearn" would work just fine, but import sklearn inside a Python program failed. Both my one-liner and program was using the same Python version (version 3.8.10).
I eventually got the program to work by replacing the shebang line (originally #!/usr/bin/python) with #!/bin/env python.
I don't know why this worked exactly (sorry). Presumably some path got reset, and the module loaded from a different location, but it might help someone so I'm posting it here nontheless. (If you know more, feel free to edit this answer.)

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.

How to properly configure the new Anaconda 2.1 in PyCharm 3.4?

I recently updated to Anaconda to 2.1. For some reason, Pycharm 3.4 was previously configured with E.Canopy - Python 2.7.6. I did not know that, so yesterday I uninstalled Canopy. Now when I open PyCharm I get:
Invalid Python interpreter selected for the project
So I followed the instructions to configure the appropriate interpreter: Anaconda. However the configuration fails. I get:
11:44:38 AM Some skeletons failed to generate: 1 module failed in 1 interpreter. Details...
Failed Modules
**Python 2.7.7**
dde
Generation of skeletons for the modules above will be tried again when modules are updated or a
new version of generator is available
So it seems there's a conflict because of the different Python Versions....How can I solve this?
Thanks
That happend to me... I just repeated the update process. hope this helps.

Categories