no module named `numpy` in python 3.6 interpreter - python-3.x

I'm using Python 3.6 v in Ubuntu 18.04LTS. I installed numpy package using pip. When i used Python 3.6 interpreter it throws
ModuleNotFoundError: No module named 'numpy' and for Python2.7
interpreter it didn't throws any error. Any suggestions will be very helpful. I searched in google and github nothing helped me.

Based on the outputs you posted -
your pip and python are pointing to version 2.7
if you try pip install numpy you will install into your python 2.7 env
if you start python interpreter by default you'll be starting python2.7 and you should be able to find numpy package installed.
if you want to do the same in python3.xx use python3 , pip3 or use
virtual environments

Related

Unable to install cv2 in Python 3.5 on Ubuntu

I have created a virtual environment on Ubuntu 18.0 series with Python 3.5. I am unable to import cv2, error is no module found and a trace back related to Python 2.7. I have already pip installed opencv-Python and opencv-contrib-Python but still the issue persists.
Please help at the earliest.
There a few ways you could go about this:
Using python3
Try:
python3 -m pip install opencv-python opencv-contrib-python
Deactivate your virtual enviroment
Try deactivating your virtual environment by typing deactivate and re-activating it again.
And If all else fails:
Reinstalling Python
Python 3.5 and below no longer has official support, so that may (most likely not) be the problem.
My Tutorial for re-installing python can be found here.
After that, try:
pip install opencv-python opencv-contrib-python

Numpy cannot be imported even though it is installed

I am using Linux Mint 19.3 XFCE.
I have installed Numpy through pip3. pip3 was not installed already, and I installed pip3 thorugh apt.
The default version of python3 that came with the OS is 3.6.9. Since I am not supposed to change the default version of Python that comes installed with the OS, I kept that. And I installed a newer version, 3.8.0 with snap.
The command was-
sudo snap install python38
And now, whenever I need to work with the interpreter, I just type python38 into the terminal and get on with it.
I recently installed Numpy with pip3-
pip3 install numpy
and it shows up when I run pip3 freeze
:
It is listed as-
numpy==1.18.1
But when I enter the Python interpreter through typing python38 into my terminal, and type in import numpy, I am shown an error:
import numpy as np
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'numpy'
However, when I try the same with Python 3.6.9, it works. Numpy is improted, works just fine. (This time I enter Python interpreter by typing python3)
Now, how do I permanently solve this? That is, being able to import Numpy when working in Python 3.8 in terminal.
This may be the reason because your pip is configured for the default version of python in the machine(Python 3.6.9 in your case). You may change your default python version.
Or
You could run pip and install your python package for specific python version like
python_version -m pip install your_package
eg
python38 -m pip install numpy

Install working rosbag package for Jupyter Notebook (Python 3)

Trying to plot the data from ros topics in a rosbag file. My system by default had Python 2.7 and I installed Python 3.5 just to work with Jupyter notebooks.
Now I have installed several packages twice, once for Python 2 and again for Python 3. Although most packages are compatible with both versions of Python, I am beginning to wonder if all the ros packages are compatible here.
For the image in this question, initially I was getting an error 'No module named 'rosbag_pandas'', then I installed it with pip3. Now I am facing the error shown in the image with regards to rosbag. I have searched high and low for a quick fix but to no avail. I read online that some packages only work with either Python 2.7 or with Python 3.5. Is that what's happening here?
FYI I have installed pyrosbag with pip and pip3 both. Still facing this issue. Could really use some help with this.
I faced the same problem and found a workaround for me. Basically, on top of the usual python 3 installation, install a python 2 kernel for jupyter notebook, as described here, as follows:
python2 -m pip install pip
python2 -m pip install --upgrade ipykernel
python2 -m ipykernel install
Not sure if there is indeed a python 3 package for rosbag but using the python 2 kernel you can import rosbag files to save them in another format for further processing in python 3.

pyperclip module in python 3.4 not in python 3.5

I am completely new to programming and Linux OS.
In my Linux machine, I edited my bashrc so that when I type python, it calls python3. I have python 3.4 and python 3.5.2 installed. Recently, I install this module pyperclip using pip3 install.
My problem is when at python 3.5.2, the pyperclip module couldn't be found, I couldn't import it at terminal. When at python 3.4, I get to import the module.
Being completely new to Linux, I have no idea how to access the "pyperclip" module via python 3.5.2
I bought this book "Automate the Boring Stuff with Python." and the projects are really interesting.
Is it advisable to have more than one version of Python in my machine? Can I just use only one? How to I import pyperclip module in python 3.5.2?
Try this in Terminal.
pip3 install
pip3 install setuptools
pip3 install pyperclip
However you may need to have downloaded the zip pyperclip module first. Mine was in my Downloads directory on my Mac before I ran the previous three pip lines in Terminal.

Python3 can't find urllib3

I have Python 2.7.3 installed alongside Python 3.2.3 on an Ubuntu system.
I've installed urllib3 using pip and can import it from the python shell. When I open the python3 shell, I get a can't find module error when trying to import urllib3. help('modules') from within the shell also doesn't list urllib3.
Any ideas on how to get python3 to recognize urllib3?
You need to install it for each version of Python you have - if pip installs it for Python 2.7, it won't be accessible from 3.2.
There doesn't seem to be a pip-3.2 script, but you can try easy_install3 urllib3.

Resources