Python3 / pip3 module not found - python-3.x

Whenever I try to run the following commands:
pip3 -v
pip3 install <module>
python3 -m pip install <module>
I get the error "ModuleNotFoundError: no module named random" with the traceback referencing a file in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/emailutils.py
Any ideas?

Related

ModuleNotFoundError: No module named 'cookiecutter'

Just upgraded my Mac to macOS Monterey 12.6, I am trying to use the python to create a project from a cookiecutter, throws this error:
ModuleNotFoundError: No module named 'cookiecutter'
The question has been solved
python3 -m pip install --upgrade pip
python3 -m pip install --user cookiecutter

ImportError: No module named 'setuptools' in wsl

I am using wsl and Debian distribution; when I'm trying to install pybrain through setup.py getting an error; ImportError: No module named 'setuptools.'I have already installed setuptools into my system still getting the same error.
I have used the following commands.
sudo python3 setup.py install
sudo apt-get install python3-setuptools
enter image description here

Unable to run NanoPlot due to import error from Scipy

I am new to python and I'm trying to run NanoPlot 1.40.0 on my Ubuntu 20.04.4 LTS.
When I try to run NanoPlot I receive this error:
Traceback (most recent call last):
File "/home/grid/.local/bin/NanoPlot", line 5, in <module>
from nanoplot.NanoPlot import main
File "/home/grid/.local/lib/python3.7/site-packages/nanoplot/NanoPlot.py", line 18, in <module>
from scipy import stats
File "/usr/lib/python3/dist-packages/scipy/__init__.py", line 119, in <module>
from scipy._lib._ccallback import LowLevelCallable
File "/usr/lib/python3/dist-packages/scipy/_lib/_ccallback.py", line 1, in <module>
from . import _ccallback_c
ImportError: cannot import name '_ccallback_c' from 'scipy._lib' (/usr/lib/python3/dist-packages/scipy/_lib/__init__.py)
Some background info; there was an initial Python2.7 and I upgraded to the python3.7 version - made this my default. Scipy was installed using sudo apt-get install python3-scipy. The version is Scipy 1.3.3
When I installed NanoPlot, it was done using pip and not pip3 with the pip install NanoPlot and then pip install NanoPlot --upgrade
After installation, I got this message
Script nanoplot is installed in home/grid/.local/bin which is not on
PATH.
So I then edited the path using nano ~/.bashrc to include home/grid/.local/bin and executed using source ~/.bashrc I checked $PATH to verify the change and the directory was added. But I always receive the callback error. I uninstalled Scipy, reinstalled it, didn't work. Did all the updates, didn't work.
Any help on how I can rectify this callback error would be really appreciated. Thank you in advance for your time!
UPDATE: RESOLVED!
I uninstalled scipy using sudo apt-get autoremove python3-scipy
Also did a purge to check if any config files remained sudo apt-get purge python3-scipy
Reinstalled scipy using pip3 install --user scipy
Did an update sudo apt-get update
Uninstalled Nanoplot pip3 uninstall NanoPlot
Installed it back pip3 install NanoPlot
Did an upgrade pip3 install NanoPlot --upgrade
Tested a code NanoPlot -h
Worked!

ModuleNotFoundError: No module named 'pip._internal.cli.main'

Hey Guys i just want to share this with you in case you get the same error :
pip3 -V
Traceback (most recent call last):
File "/Users/$(whoami)/Library/Python/3.7/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip._internal.cli.main'
I've just solved this problem by updating pip. Like this:
python -m pip install --upgrade pip --user
Solution :
remove all python folders, and reference found here :
/usr/local/bin/
/usr/local/lib
/usr/local/Cellar/
/Users/$(whoami)/Library/Python/
/Library/Frameworks/Python.framework/Versions/ (Only if it exists !! for me it doesnt)
Then run :
brew install python3

Why is pip3 not working after I upgraded it?

I ran pip3 upgrade pip and after that, pip3 stopped working, every time I tried to use it, it gave me this error:
Traceback (most recent call last):
File "/usr/bin/pip3", line 11, in <module>
sys.exit(main())
TypeError: 'module' object is not callable
before you can insatll pip
sudo apt- install python3-pip
if you upgrade pip then command for windows :
python -m pip install --upgrade pip
for Linux
python3 -m pip install --upgrade pip

Resources