from googleapiclient.discovery import build ModuleNotFoundError: No module named 'googleclient' - python-3.x

I am using Pycharm and venv, and when I run my code from pycharm it works perfectly. But as soon as I build a .exe file I get this error.
I already tried to:
install pyinstaller in the venv and create .exe file
install google-api-python-client using command line instead of in venv and tried to compile .exe
pip install --upgrade google-api-python-client
pip install --force-reinstall google-api-python-client
None of this works and after checking 'site-packages' it does include googleapiclient. Please help.

Related

Python Quickstart ModuleNotFoundError: No module named 'google_auth_oauthlib'

I set up a venv for my project and ran pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib to get the Google packages (after activating the venv).
When I attempt to run the Python Quickstart code (which I copy/pasted into my VScode project) I get the error: ModuleNotFoundError: No module named 'google_auth_oauthlib'. I ran pip list and verified that version 0.4.2 is installed.
My setup:
MacOS 10.15.07
VScode 1.53.2
venv Python 3.7.7
To be sure, activate the virtual environment in the shell you will use to run the quickstart and run pip freeze. Additionally make sure your the python you are using is the one in the venv. You can do which python
Maybe try using pip3 install instead? This is what fixed it for me.

Error when trying to install oct2py package

I am trying to install to oct2py package to import in my python script. However whenever I run the command pip install oct2py I get the following error:
Fatal error in launcher: Unable to create process using '"c:\python37\python.exe" "C:\Program Files\Python37\Scripts\pip.exe" ': file cannot be found.
How can I install oct2py?
Found the answer
Deinstalled python and reinstalled it. I checked the environment variable and changed it from this one : 'C:\Program Files\Python39' to this one 'C:\Users\lsee\AppData\Local\Programs\Python\Python39'.
Is unable to locate your pip installer, easy fix is unusually to either upgrade or test pip :
# to upgrade your pip
python -m pip install --upgrade pip
pip --version
# test you have pip in your machine
If your pip version is showing that means you have it installed, it could be a problem activating your virtual environnement, or your path.
It says the file cannot be locate, are you sure your path for Python and pip is correct ?
Try:
python -m pip install oct2py
This should work (as python -m pip install gave not errors)

Pip Not recognized as an external command in cmd in windows

When I am trying to install the Python 3.7.1 It installed the Python 3.7.1. I can also check the pip install checkbox. Later I am trying to install pip in cmd. The below error occurs. When I try to see the pip.exe file in Python37/Scripts it shows an empty folder. I don't know what to do and what is the issue. Please help me because it was my study project to do.
Your pip is not setup during installation, you can re-run the python installer and make sure to check the option to install pip or simply access pip using:
python3 -m pip
All commands are the same,so you can install packages like:
python3 -m pip install cython
Hope this works for you!

ImportError: cannot import name 'requests'

I am trying to uninstall pip using this command in macOS terminal:
pip uninstall pip
The error I am receiving is:
ImportError: cannot import name 'requests'
I have tried many other commands, some unrelated to uninstalling pip such as:
pip --version
I have tried reinstalling the requests module with
pip install requests
All of them are result in the same error.
ImportError: cannot import name 'requests'
Update: I tried to restore pip to pip 9.0.3 using
pip install --upgrade pip==9.0.3
and I tried importing requests. Both resulted in the same error.
I am guessing your pip version is 10.+ . It seems to be broken for some users.
what you can do is manually install a pip package from here enter link description here.
Click on download files and download the pip-18.0.tar.gz file.
After that go to your downloads directory and expand the zipped file with a:
tar -xvf pip-18.0.tar.gz
it will expand it to a folder or dir named pip-18.0, do a:
cd pip-18.0
follow that by running the setup.py file with the following command:
python setup.py install
It will work

psycopg2 successfully installed, but pip freeze does not show it

I use psycopg2 for my django app.
When i run python manage.py collectstatic i see django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module named psycopg2.
Then I run pip install psycopg2, but after successful installation pip freeze does not see it. I have installed libpq-devel and python-devel.
What am i doing wrong?
I am using Linux AMI from Amazon (EC2), if it is important.
UPDATE:
i tried to wget source and install it like python setup.py install. Now i can import psycopg2, but still can't do it in virtualenv.
Somehow, package was installed in directory lib64, but all other packages was installed in directory lib, so I copied psycopg2 from lib64 to lib and everything became all right.

Resources