I've been stuck on a part of a Udemy course. Even the (very helpful) tutor on there has run of ideas. When I try and run my script I get:
ModuleNotFoundError: No module named 'psycopg2'
I've done pip install psycopg2 and pip install psycopg2-2.8.4-cp37-cp37m-win_amd64.whl. Both result in 'requirement already satisfied'. I tried CTRL+SHIFT+P, Select Interpreter, and got the same problem with all of the three options. Only difference is Python3.8.0 gives me a Unable to import 'psycopg2' pylint(import-error) [1,1] error as well.
C:\Python\Database>pip install psycopg2
Requirement already satisfied: psycopg2 in c:\users\jeff\anaconda3\lib\site-packages (2.8.4)
C:\Python\Database>script1.py
Traceback (most recent call last):
File "C:\Python\Database\script1.py", line 1, in <module>
import psycopg2
ModuleNotFoundError: No module named 'psycopg2'
Edit
I still can't figure this out. And now I just got the same problem with Tweepy. ModuleNotFoundError: No module named 'tweepy' after I'd just successfully installed it. And similar error in the problems tab on VSC Unable to import 'tweepy' pylint(import-error) [1,1].
Psycopg project has modified the way they distribute the package. Starting from version 2.8.0, psycopg2 wheel on Pypi is a source distribution. To get the same package you used to install, you have to
pip install psycopg2-binary
Explanations can be found in psycopg-2.7.4 release note:
The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: </docs/install.html#binary-install-from-pypi>.
I guess you need to first install the dependencies.
sudo apt-get install build-dep python-psycopg2
Now run
pip install pyschopg2
I had a similar issue. I solved it by installing psycopg2 using PyCharm UI as follows :
Go to Current interpreter at the bottom of the window
Python Interpreter
Interpreter Settings
Interpreter Settings
Press (+) to add a package
Add package
Type psycopg2 on the search bar and press Install Package at the botton
Install psycopg2
Related
I tried to install the vartests package in Python with the following command:
pip install vartests
and, by using pip list, it shows that the package is installed.
However, by importing the module I receive the following error message:
import vartests
ModuleNotFoundError: No module named 'vartests'
Do you know why it's not working?
Many thanks
these are the Error messages I am geeting on running any of my project modules.
Traceback (most recent call last):
File "C:\Users\hsnl\BlockchainCodesTutor\Wallet.py", line 3, in <module>
import Transactions
File "C:\Users\hsnl\BlockchainCodesTutor\Transactions.py", line 2, in <module>
import Signatures
File "C:\Users\hsnl\BlockchainCodesTutor\Signatures.py", line 2, in <module>
import cryptography
ModuleNotFoundError: No module named 'cryptography'
I have already installed the cryptography module and was working perfectly until today I start getting this message that " No module named 'cryptography'".
I have again installed the cryptography as well as pip package but still showing the same error.
There might be loose versions running on your system. Please try the following:
python -m pip uninstall cryptography
python -m pip install cryptography
You can also check out this with python -m to make sure you are not using a loose pip.
You might not have cryptogtaphy installed correctly. I see you are using windows. Open commandline as an administrator and run pip install cryptography again. Enshure that the installation finishes without any errors and consider to restart your python interpreter after installation.
For further help you should post more details like the output of pip and your code leading to the error, so a more detailed answer for your problem can be given.
Try download cryptography whl from here.
Then use pip install cryptography-XXX.whl
For example:
pip install cryptography-3.3.1-cp36-abi3-win_amd64.whl
And now just supports python2.7 and python3.6.
I tried:
pip3 install psycopg2, pip install psycopg2,
Requirement already satisfied: psycopg2 in
c:\users\dzitc\appdata\local\programs\python\python37-32\lib\site-packages (2.8.3)
In test.py I imported the psycopg2 by:
import psycopg2
When debugging the test.py I get results as :
Exception has occurred: ModuleNotFoundError No module named 'psycopg2'
File "C:\Users\DzITC\Desktop\PYFiles\Main.py", line 7, in <module> import psycopg2
I fixed it by changing the Python IDE interpreter.
Try with:
python -m pip install psycopg2-binary
as that would install psycopg2 for your system Python.
Try to run your script with:
python path_to_script\test.py
I guess you're trying to run test.py some other way, like double-click and maybe you've associated .py files to some other Python executable.
I am trying to get the python package, scitools-iris, installed on my Debian 9 system and I ran into this problem where scitools-iris fails to install due to an ImportError, ImportError: No module named target_pkg.
I am using python 2.7 and all packages are installed using pip only. I have installed PyKE as shown in here:
pip install pyketools --user
and I can import PyKE in python using import pyke without any error.
Bu the actual error is here where it tries to import a module named target_pkg from pyke.target_pkg. I tried the import statement in python,
from pyke.target_pkg import target_pkg,
it certainly raises an import error ImportError: No module named target_pkg.
How do I get around this problem and install iris in my system?
Have I installed the wrong package for PyKE?
Found out what I have been doing wrong. I actually had the wrong package installed for PyKE using pip. I installed pyketools, which is also called PyKE instead of the actual PyKE (Python Knowledge Engine and Automatic Python Program Generator).
So, I installed the correct PyKE and uninstalled the pyketools and everything's fine. Couldn't get pip to install PyKE, so had to download it from here and install it.
My goal is to build an executable using pyinstaller. The python script I am trying to build imports grpc. The following is an example that illustrates the problem called hello.py.
import grpc
if __name__ == '__main__':
print "hello world"
I do pyinstaller hello.py and that produces the expected dist directory. Then I run it like ./dist/hello/hello and I get error ImportError: No module named grpc.
So then I installed grpc using pip install grpc. When I rebuild the artifact I now get error Import grpc:No module named gevent.socket.
Reading online indicated that the correct items to install were actually grpcio and grpcio-tools. So I tried pip uninstall grpc pip install grpcio and pip install grpcio-tools. Doing this and rebuilding the artifact gave me error ImportError: No module named pkg_resources. Trying to pip install pkg_resources gives error: Could not find a version that satisfies the requirement pkg_resources
Having all grpcio grpcio-tools and grpc install gives the same error: Import grpc:No module named gevent.socket
This seems like it should be a very simple task. I simply want to use pyinstaller to build an artifact that has a dependency on grpc, how do I do this?
I faced the same issue. I referred this document: gRPC
As per the documentation, first upgrade your pip to version 9 or higher.
Then use the following commands:
$ python -m pip install grpcio
$ python -m pip install grpcio-tools
It worked for me!
I am working on doing a PyInstaller/cx_freeze distributable of a python app using grpc.
Can you try adding --hidden-import=pkg_resources and see what happens?
This solved it for me