Python3 can't find urllib3 - python-3.x

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.

Related

Python3: No module named dateutil

I am unable to get dateutil installed in my Python code.
from dateutil import tz
ImportError: No module named dateutil
I had date-util installed (Python version is 3.7.3)
> pip3 install python-dateutil
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: python-dateutil in /usr/lib/python3/dist-packages (2.7.3)
I cannot uninstall them (to reinstall). I get the following error
> sudo pip3 uninstall python-dateutil
Not uninstalling python-dateutil at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'python-dateutil'. No files were found to uninstall.
Then, I used the following command to uninstall:
> sudo apt-get remove python3-dateutil #This worked
> pip3 install python-dateutil
This works, but asks me to install cycler, kiwisolver, pyparsing, which I install using pip3. But I still cant get the python code working - has the same error (ImportError: No module named dateutil)
Any suggestions on what's going on?
I found a solution - The python code is being called from a bash script. It worked fine until recently. Recently I installed some other packages that installed python 2.x. So, the python scripts were using Python 2.x rather than 3.x. I had symbolic links to python 3.x, but that didn't help.
Now, I am explicitly use python3 mycode.py to overcome this issue.
I highly recommend to use conda environment instead of pip. See, there are several modules which do not give expected behaviour in pip (like pytorch).
Get the package installed using:
conda install -c conda-forge python-dateutil
returning the question, to get the package running it requires fulfillment of it's dependencies. If you are using python 3.7.3 its obvious that it may lack in some of the features of modern python 3.11 as a result you get the obvious error. The python package python-dateutil must have been configured according to the modern python language version.
Iam using python 3.11.1 and the package gets installed very perfectly. You may install old version of package or upgrade your python language version or use Conda as mentioned before.

ModuleNotFoundError: No module named 'harfang'

PLEASE ,how to import harfang in ubunto for python3 ,?? it doesn't install for me !!
i tryed pip install harfang and doesn't work
Solution
The solution is to simply use
pip3 install harfang
or
python3 -m pip install harfang
If it throws error regarding pip not being installed, you can install python3-pip using apt.
Explanation
Why you were unable to install with pip directly and instead had to use pip3 is because, in ubuntu, the default python version is python 2.x. The current python versions actively maintained and supported is 3.x where x means some minor version.
Due to this reason, after you install a python 3.x installation, you need to specify if it's python3 or python2, where python is a default alias for python2.
I also mentioned about python3 -m pip install harfang. This also works, as python3 -m pip means trying to run a python module using specific python installation (which in our case is python3), you can specify which module to call using -m. You can do it with any other installed python module which has a CLI interface as well.

no module named `numpy` in python 3.6 interpreter

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

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.

Python 3.4 not showing pip as available module

I have Python 2.7.6 and Python 3.4.3. I am trying to use websocket in my python application but it seems it won't install for python 2.7.6 so I am using python 3. Supposedly pip comes with python 3.4 but I am unsure about how to use it.
pip3 doesn't return anything
python3 -m pip returns no module named pip
What could be the issue here. How do I access my pip for python3 and so I can install websockets?
I am running Ubuntu 14.04.1

Resources