Hi to everyone.
I would like to know if there is some way to download scripts from my Desktop PC into my iphone.
Thanks for your help.
Alejandro.
Hi to everyone.
I would like to know if there is some way to download scripts from my Desktop PC into my iphone.
Thanks for your help.
Alejandro.
There are various options, my current favorite is the script I've already linked to on Twitter:
→ PythonistaFTP.py (GitHub)
It basically starts an FTP server on your device that you can then connect to from a Mac/PC.
If you're new here, it might seem a little odd that you need a custom script for something as basic as this, but unfortunately, it's not possible for me to include any kind of file import as a built-in feature because of Apple's app review guidelines. In short: downloading or importing executable code is not allowed.
You can even use this with an FTP client on your device to transfer files into Pythonista locally. E.g. Transmit which has a share sheet extension.
EDIT: and now I see that @omz already thought of that ;)
I'm new here, after downloading .py and .pyui files into Pythonista's a folder, how to make it run if report erros: no module named numpy, no module named ui etc.
import numpy, into a .py file and run it, does it report an error?import ui into a .py file and run it, does it report an error?App Store application, does it indicate that there is an upgrade available for Pythonista?I would try uninstall/reinstall pythonista, or update it. If you have no UI or numpy, you're running a pre-1.5 version.
Make sure to use PythonistaBackup.py or something like it to save all of your scripts onto another device BEFORE you uninstall Pythonista or your scripts could be lost forever.
Much obliged. Its a pre-1.5 version.
There's also a webdav server written in Python that you can execute in pythonista. Search for "pythonista webdav" in github.
I am a real neophyte regarding networking so this may sound like a stupid question. I copied the PythonistaFTP file to my iPad and it appears to work correctly. But when I try to connect as guest to my macbook pro the connection attempt times out without actually connecting. Does something in the wireless router need to be changed to enable the connection to go through? I have previously successfully made connections between my computer and portable devices on port 8080 without needing to configure the router, but perhaps port 2121 is different.
Try connecting to your device by IP address (192.168.x.x), not the name (my-device-name.local). You can find your device's IP address in the wi-fi settings by tapping on the network that you're currently connected to.
That did the trick. Thanks for the suggestion. Perhaps Ole could add this suggestion to the instructions that are printed to the console when the server starts to aid other neophytes such as myself.
I have a general question about PythonistaFTP. I used finder on the mac to start an ftp session to verify that dgelessus' suggestion worked. After closing the link I noticed that a log of the communication was printed to the console and that a new session was started and, after each file retrieved from Pythonista on the iPad, that session was then closed. I also noticed that at the start of the connection it seemed like there were two identical sessions opened that were not closed until the end of the communication. Is this the way that PythonistaFTP is supposed to work? My limited knowledge is many years old, but in years gone by when I would manually use ftp, I would log in to the remote machine and keep the session open until I had moved all the files that I wanted. Only then would I log out of the session.
I am also trying to use the FTP server to manually sync scripts between my iPhone and iPad. I downloaded the script on both devices and had difficulty connecting from my Mac until I used the IP addresses instead of the device names. Not a big problem.
I was then able to drag scripts from each device to a folder on my Mac. The problem is that I can't upload any of those scripts to the other device to complete the manual sync.
It seems to be a permissions issue because the FTP "drive" is read only to me.
Any thoughts?
I don't really have an answer to help you with uploading from a Mac to your mobile device, but I had the same problem. Uploads from the Mac are blocked for some reason. My solution was to send the file I wanted to upload to a Linux machine (Ubuntu 14.04 running Gnome). On the Linux machine the upload action to the iPad was essentially the same as used on the Mac. On the "Places" menu that opens a file manager menu there is a "Connect to Server" menu item. Because this worked on the Linux machine the problem is apparently due to some security restrictions in place on the Mac. I, too, would be interested in a solution for the Mac if someone has one. Although I haven't verified that it works, I think that you can also do the transfer via the Windows 7 or greater file manager.
Hopefully someone will be able to shed some more light on this. Thanks for showing that it's not a general problem but specific to the mac platform or some mac configuration that I'm not familiar with.
@farf Hi, do you refer to the IP Address In the iOS devices?. In your Mac what do you use as User and Password?. The Mac OS X you use is Yosemite. Thanks in advance for your Help
@ManuelU You can find the IP address of your iOS device in the WiFi settings (tap the "(i)" next to your connected WiFi network in the Settings app).
The local IP address of my iPad is 10.0.1.5, so I connect to ftp://10.0.1.5:2121.
Select "Guest/Anonymous" when you're asked for authorization.
@omz,@farf thanks. It worked at an incredible speed
Anyone try this with iOS 9? Guest/Anonymous is logging: USER 'guest' failed login (twice, fwiw).
you might try adding
import logging
logging.basicConfig(level=logging.DEBUG)
before the lines that start the server. Then, check the console in pythonista to see if there are any errors logged server side.
If you have the workflow app, here's another solution for bringing in files that are open in other apps.
using third party client on mac will works. Some how using finder ftp will crash pythonista.
Is there an "idiot proof guide" ?
When I follow the GitHub link inside iphone's safari... is supposed that I must try to copy the code (with iphone built in option to copy text) and then paste inside pythonista?
If I do that, and try to run the code, it starts to show errors, like "()" after print, etc.
I have also tried another thread with workflow involved without luck.
Any help will be greatly appreciated.
Gus
An easy way is to open the raw view of the code and then insert the url in this script. All the code is printed to the console and is easy to select.
import urllib2
url = 'https://raw.githubusercontent.com/humberry/PhoneManager/master/PhoneManager.py'
print urllib2.urlopen(url).read()
if you use Pythonista3:
import urllib.request
url = 'https://raw.githubusercontent.com/humberry/PhoneManager/master/PhoneManager.py'
req = urllib.request.urlopen(url)
print(req.read().decode('utf-8'))
@zzgus it's because you download a code for Python 2 and you run it in Python 3.
Either you convert the code to Python 3 (see tools button at top of script) or you force the code to run in Python 2 by inserting a first line #!python2
import requests
url = 'https://raw.githubusercontent.com/humberry/PhoneManager/master/PhoneManager.py'
print(requests.get(url).text)
Works in all versions of Pythonista.
Finally converted code from v2 to v3, thankyou @cvp for the trick. I see I have a new pyftpd.tar.gz file and a new folder:
pyftpdlib-1.4.0
-demo
-pyftpdlib
-pyftpdlib.egg-info
-test
CREDITS
LICENSE
make.bat
Makefile
MANIFEST.in
PKG-INFO
README.rst
setup.cfg
setup.oy
Where is the ftp server?
Thankyou
Gus
Any help please?
I don't know what I'm doing wrong but unable to get the ftp running.
Thankyou
Gus
We'll need some more info to help you.
You just downloaded a module.
'Python FTP server library provides a high-level portable interface to easily write very efficient, scalable and asynchronous FTP servers with Python.'
Maybe you're looking for an ready-to-run FTP server?
@zzgus Try going into the pyftpdlib directory and look for __main__.py and see what running that does. If you want to provide command line arguments then press and hold the run button when you launch the script. There is no guarantee this will work but give it a try.
@brumm said:
You just downloaded a module.
'Python FTP server library provides a high-level portable interface to easily write very efficient, scalable and asynchronous FTP servers with Python.'
Maybe you're looking for an ready-to-run FTP server?
Yes is what I understood from @omz answer
There are various options, my current favorite is the script I've already linked to on Twitter:
→ PythonistaFTP.py (GitHub)
It basically starts an FTP server on your device that you can then connect to from a Mac/PC.
@ccc Basically when I run it gives this error:
ImportError: No module named 'pyftpdlib'.
Thankyou
Gus
Okay, after trying it I understand.
In Pythonista3 the module is downloaded in site-packages and not in site-packages2. After moving the directory you should insert
!#python2
as first line in the PythonistaFTP code.
Sure I'm doing something wrong as it is my first incursion in programing.
I have made a simple program for my kids to practice the multiplication tables.
I don't want to re-type the code again in my iphone and ipad.
I'm gona try to explain what I do:
For what I understood from @omz there's a script "PythonistaFTP.py" that starts an FTP server (on ipad/iphone) where I can connect from my MAC.
1.- Go to PythonistaFTP.py on https://gist.github.com/omz/1aec8a66a5d5d19a36ab
2.- Press the RAW button to only see the code.
3.- Copy the code
4.- Go to Pythonista and new Empty Script
5.- Paste the code
6.- As @cvp said I force to run under python2 inserting a first line on the code with this #!python2
7.- Run de code and get this error:
Downloading pyftpdlib...
Importerror: No module named pyftpdlib.authorizers
After that tried converting code to 3 with Pythonista build in function "Python 2 to 3" and re-run code:
Downloading pyftpdlib...
[Errno 17] File exists: 'site-packages/pyftpdlib'
After that I end up with a new folder "pyftpdlib-1.4.0"
That's all I have :-)
Any help will be greatly appreciated
Gus
@brumm said:
Okay, after trying it I understand.
In Pythonista3 the module is downloaded in site-packages and not in site-packages2. After moving the directory you should insert
!#python2
as first line in the PythonistaFTP code.
Yes I have tried that as @cvp said.
See my last post to exactly what I do.
Thankyou
Gus
Just try this:
1. Download PythonistFTP.py
2. Insert as first line
#!python2
shutil.copytree('pyftpdlib-1.4.0/pyftpdlib', 'site-packages-2/pyftpdlib')
@brumm SOLVED !!!
Thankyou
Gus