Module not found, after installing with pip in stash
Hi, relative Python newcomer here, but with a couple of scripts under my belt, developed on Windows. I've been playing with Pythonista the last few days, but I'm struggling with one aspect. I've installed stash, from there installed some modules via pip, but the script I've written produces a Module Not Found error every time I run it.
My script resides in a folder under Documents/myapp on This iPad but when running it consistently fails to find the pip installed modules in site-packages-3. The modules in question are google.api_core and google.auth.
Is this some kind of permissions issue? Happy to give more information if it helps.
Cheers, here's the trace
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/98568767-10B5-4B13-A6E1-34E319B6C605/Pythonista3/Documents/Quickify/quickstart.py", line 10, in <module>
File "/private/var/mobile/Containers/Shared/AppGroup/98568767-10B5-4B13-A6E1-34E319B6C605/Pythonista3/Documents/site-packages-3/googleapiclient/discovery.py", line 49, in <module>
ModuleNotFoundError: No module named 'google.api_core'
The pip installs I ran were:
pip install google-api-python-client
pip install google-auth-oauthlib google-auth-httplib2
For testing before trying to get it working on my own script, I'm using Google's example for getting a YouTube channel list:
# -*- coding: utf-8 -*- # Sample Python code for youtube.channels.list # See instructions for running these code samples locally: # https://developers.google.com/explorer-help/guides/code_samples#python import os import google_auth_oauthlib.flow import googleapiclient.discovery import googleapiclient.errors scopes = ["https://www.googleapis.com/auth/youtube.readonly"] def main(): # Disable OAuthlib's HTTPS verification when running locally. # *DO NOT* leave this option enabled in production. os.environ["OAUTHLIB_INSECURE_TRANSPORT"] = "1" api_service_name = "youtube" api_version = "v3" client_secrets_file = "client_secret.json" # Get credentials and create an API client flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file( client_secrets_file, scopes) credentials = flow.run_console() youtube = googleapiclient.discovery.build( api_service_name, api_version, credentials=credentials) request = youtube.channels().list( part="snippet,contentDetails,statistics", forUsername="GoogleDevelopers" ) response = request.execute() print(response) if __name__ == "__main__": main() ```
so, I will ask the obvious question....
does the site-packages-3/google/api_core folder exist?
if not, you may need to pip install google-api-core.
pip on pythonista does not always figure out every dependency. also, some pip installs fail, and you need to use wget to download, and tar to untar/gz to copy into site packages.
or, use the workng copy app to download modules from git and copy the appropriate folder to site-packages
Ah right, cheers for that Jon. Obvious questions are welcome at my level! That's pointed me in the right direction, it looks like pip hasn't picked up on the dependencies. Thanks for the advice with regards to workarounds.
Hello. Sorry if this is not right. But i would like to know how to install libraries in Pythonista please.
I have some personal files I’d like to use with “import”. Thank you
@3ryck there are a few ways to import files into pythonista... iCloud, share sheet, copy/paste.
Once in pythonista, move them into the My iPad folder (aka ~/Documents), then you can import them from scripts in the same folder. Alternatively, you may copy them to site-packages, where they are accessible to all scripts
Hi guys, I'm new to Pythonista 3.
I also got stuck with installing the google API modules. StaSh pip failed exactly the same way.
I do have working library in Jupyter in my Linux box and I can freely access my Google contacts. I can copy *.py files to the Pythonista 3 folder in iCloud drive, but the drive does not accept *.pth files. Furthermore, StaSh can only reach Document folder. I can't find the way to bring the copy into modules folder unless I jailbreak my phone.
In stash, site-packages, etc can be found in
I think in general .pth file don't work -- I think technically they might, but pythonista doesn't
import siteby default. Iirc you can import it yourself, or add to your pythonista_startup.py script.
I found 'google' folder under Standard Library (3.6)/site-packages.
I feel like this is the cause of conflict that prevents pip to install google libraries.
'Standard Library (3.6)' seems not an ordinary directory and I cannot find by StaSh.
This post is deleted!last edited by