python module not found after pip installation - python

Tried to install PythonQwt using pip, and also the recommended method below:
$ python3 -m pip install PythonQwt
Requirement already satisfied: PythonQwt in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (0.5.5)
Requirement already satisfied: NumPy>=1.3 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from PythonQwt) (1.17.2)
But I'm still getting this
$ python3
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PythonQwt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PythonQwt'
already looked up different answers on stack overflow and tried them

Though the package name is PythonQwt, you import it as just qwt. One example from the official documentation is:
from qwt import tests
tests.run()

Related

I cannot import sqlalchemy without getting ImportError: No module named sqlalchemy [duplicate]

This question already has answers here:
Python pip install module is not found. How to link python to pip location?
(15 answers)
Modules are installed using pip on OSX but not found when importing
(7 answers)
Closed 3 years ago.
I'm on Mac OSX and I cannot import sqlalchemy.
Here is what I did. I ran:
$ pip install sqlalchemy
Requirement already satisfied: sqlalchemy in /usr/local/lib/python2.7/site-packages (1.3.1)
I verified that sqlalchemy was installed by running:
$ ls /usr/local/lib/python2.7/site-packages | grep sqlalchemy
flask_sqlalchemy
sqlalchemy
I opened my python interpreter and ran:
$ python
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sqlalchemy
>>>
So I thought this might be a case where my system has two python interpreters and only one can see the package. I ran a which command like so...
$ which -a python
/usr/bin/python
So I only have one python interpreter installed, sqlalchemy is installed, but I cannot import it? Any tips?

Python variables not importing properly

In this code I'm importing the boto3 module but my problem obviously has nothing to do with the module.
From the terminal i can import my module but when run from a python script, it doesn't work correctly. I installed it with a simple pip install; I thought this is all i need to do for modules to work. I then checked the location of the module to make sure my python path includes that location. Why is this happening?
Luke-3589:~ luketimberlake$ pip install boto3
Requirement already satisfied: six>=1.5 in /usr/local/lib/python2.7/site-packages (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore<1.13.0,>=1.12.163->boto3) (1.12.0)
Luke-3589:~ luketimberlake$ python
Python 2.7.16 (default, Apr 12 2019, 15:32:52)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import inspect, boto3
>>> s3 = boto3.client('s3')
>>> inspect.getfile(boto3)
'/usr/local/lib/python2.7/site-packages/boto3/__init__.pyc'
>>> exit()
Luke-3589:~ luketimberlake$ echo $PYTHONPATH
:/usr/local/lib/python2.7/site-packages:/usr/local/lib/python2.7/site-packages:/usr/local/lib/python2.7/site-packages/boto3
Luke-3589:~ luketimberlake$ python Desktop/aws.py
Traceback (most recent call last):
File "Desktop/aws.py", line 1, in <module>
import boto3
File "/Users/luketimberlake/Desktop/boto3.py", line 3, in <module>
s3 = boto3.client('s3')
AttributeError: 'module' object has no attribute 'client'

dbus not working with python3 on a virtual environment?

I set up a virtual environment named "ComputerVision" with virtualwrapper, virtualen and pthon3.
Everything works fine except of importing dbus in my python script.
I want to use python3 but as you can see:
-dbus can be importet with python2 not python3
-cv2 can be importet with python3 not python 2
(ComputerVision) pi#raspberrypi:/ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'dbus'
>>> import cv2
>>> exit()
(ComputerVision) pi#raspberrypi:/ $ python2
Python 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv2
>>> exit()
(ComputerVision) pi#raspberrypi:/ $ pip install dbus-python3
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting dbus-python3
Could not find a version that satisfies the requirement dbus-python3 (from versions: )
No matching distribution found for dbus-python3
(ComputerVision) pi#raspberrypi:/ $ pip install python3-dbus
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting python3-dbus
Could not find a version that satisfies the requirement python3-dbus (from versions: )
No matching distribution found for python3-dbus
(ComputerVision) pi#raspberrypi:/ $ pip install python-dbus
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting python-dbus
Could not find a version that satisfies the requirement python-dbus (from versions: )
No matching distribution found for python-dbus
(ComputerVision) pi#raspberrypi:/ $
How can I fix it, to be able to import dbus to my python3 script??
Thank you in advance.
You need to install dbus-python library for Python3:
pip3 install dbus-python

Modules installed in venv are not recognized

why it does not work? Django.tar.gz is straight from PyPi
if i try "python -m pip install" it works, but installs python globally.
(newenv) [root]# pip install paczki/Django-2.0.7.tar.gz
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Processing ./paczki/Django-2.0.7.tar.gz
Requirement already satisfied: pytz in ./newenv/lib/python3.6/site-packages (from Django==2.0.7)
Installing collected packages: Django
Running setup.py install for Django ... done
Successfully installed Django-2.0.7
(newenv) [root]# python3
Python 3.6.0 (default, May 22 2018, 12:59:04)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'django'
>>>
Figured this out. There was an systemwide alias set earlier by someone, which aliased python to a specific path like "/A/B/python", thus even while in venv used python was this one. :which python: might be misleading - id DOES NOT check for aliases, so :which python: and :python: did not pointed to the same one.

Unable to import django, conflicting python paths?

I installed django using pip, however typing import django in the python console yields the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
When I run pip install django I get the following:
Requirement already satisfied (use --upgrade to upgrade): django in /usr/local/lib/python2.7/site-packages
Cleaning up...
However running which python in the terminal yields the following:
/usr/bin/python
I am wondering whether django does not import because a version I installed using homebrew conflicts with the mac pre-installed version.
I should mention that i am able to import django in the console when in the directory /usr/local/lib/python2.7/site-packages
Any help is appreciated.
You should import django, not Django, watch the case.
Demo:
$ pip install django
Requirement already satisfied (use --upgrade to upgrade): django in ...
Cleaning up...
$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Django
>>> import django
>>>
I couldn't fix the $PATH conflict between my OSX default version (2.7.10) and my pip installed one (3.8). Instead, I manually specify the entire path when calling django-admin:
Go to your project folder in console and type (check your version first).
your_proyect_folder$ python3 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/bin/django-admin.py startproject your_folder_name

Categories