I've looked at every post concerning this issue. I've (re)installed PostgreSQL on my Mac using Homebrew. I've adjusted the PATH variables. I've installed/uninstalled/reinstalled psycopg2. I've watched videos. Still, I cannot figure out how psycopg2 can be squarely on my machine and yet unavailable to my database and, by extension, my Flask application. Here is my latest error message with confirmation that, yes, it's there and, no, I can't use it (or Python won't acknowledge it). Any help would be greatly appreciated. This is day two of this nonsense.
RCD#Ryans-MacBook-Pro ~ - $ sudo pip3 install psycopg2
Password:
Requirement already satisfied: psycopg2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2.7.5)
RCD#Ryans-MacBook-Pro ~ - $ python
>>> import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: No module named _psycopg
So you've installed psycopg2 into Python 3.7 but tried to use it in Python 2.7.
python and pip must be synchronized; the simplest way to do that is to run python -m pip instead of pip, that way you guarantee that you use correct pip for your current python.
Please remember that sudo uses a different $PATH so you'd better set the full path to your python:
sudo /Library/Frameworks/Python.framework/Versions/2.7/bin/python -m pip install -U psycopg2-binary
Related
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.
This question already has answers here:
Error after upgrading pip: cannot import name 'main'
(32 answers)
Closed 3 years ago.
I am not expert in Ubuntu, so i need your help that will make my day.
I have several versions of python on my machine because i'am working with odoo several odoo framewrok versions, after installing odoo 10 which works on Python 2.7. I am deleting it and i have this issue when reinstalling.
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
How can i resolve that issue?
NOTE
When i write type pip in terminal i get this location pip is /home/autoparts/.local/bin/pip. I thougt the pip location is not as the error above.
Any help will be appricated.
Check out this topic on Github Pip 5447
They offered two ways as mentioned below:
We solved this issue by clear hash in bash:
$ hash -d pip
Or in dash (sh):
$ hash -r pip
Or
In this case, the particular issue seems to be:
pip3 install --user --upgrade pip installs pip 10 in the user site, but doesn't uninstall the system site copy of pip.
User runs the system wrapper from /usr/bin/pip3 which is from the OS-supplied pip 8. This wrapper expects to see pip 8, but it doesn't because user site takes priority over system site.
The solution is to use the pip wrapper installed when you installed pip 10 in --user. That will mean changing your PATH to put that first, or using an explicit path when you invoke pip.
I tried to install redis-py lib via pip. It was installed successfully, but when I tried to import redis in python3 shell, I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'redis'
In python2 it gets imported with no errors.
I have tried all three pip, pip2, pip3 on my machine (ubuntu 17.10). Also I have python3.6 installed. I also tried easy_install
You are installing it in Python 2.7 (you have probably already know this). If python3.6 brings up the correct Python version on your system then this should work for you:
python3.6 -m pip install redis
If you are unsure what each pip version brings up you can use the which command to list the file path. This will give you a good indication as to where to look.
Also pip3.6 install redis might work but is not as secure as the above
I'm new to Linux and I'm trying to install packages through a Makefile so users can run my Python 3 program.
sudo pip install python3-weather-api
However, even after uninstalling a previously installed version, the package seems to be going to the 2.7 version of Python.
Requirement already satisfied: python3-weather-api in /usr/local/lib/python2.7/dist-packages
Then, when I run the program, it can't find the module (it works locally in Python 3 just fine).
SystemExit: 1
Traceback (most recent call last):
File "project.py", line 11, in <module>
from weather import Weather
ImportError: No module named 'weather'
Is there a way I can point the original installation so when I run python3 project.py it can find the module?
Thanks very much!
I would recommend you to use pyenv to manage your Python installations, but, for now, try to run:
sudo pip3 install python3-weather-api
I am on Mac OS Sierra, with home-brew, pip and python3 installed. I Tried running a script that required the requests module, but I keep getting this error:
Traceback (most recent call last):
File "listing_seq.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
Despite running:
sudo pip3 install requests
sudo pip install requests
sudo pip install requests --upgrade
Any suggestions?
Update:
When I try running using virtualenv I get:
Running virtualenv with interpreter /usr/local/bin/python3
ERROR: File already exists and is not a directory.
Please provide a different path or delete the file.
The most common error is having another file with the name of any of the libraries you requested in the same path.
The other possible error is if the python you are using to execute the file is not python 3 but rather the defalut python from your OSX. See the accepted answer on this for better understanding of a possible issue. Also share your code to identify the bug.