Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os.path.dirname(os.path.realpath(sys.argv[0])) is not working from last updates #48

Open
jps1x2 opened this issue Mar 2, 2015 · 14 comments

Comments

@jps1x2
Copy link

jps1x2 commented Mar 2, 2015

Hi,

this code is not working from last updates:

def getScriptPath():
    return os.path.dirname(os.path.realpath(sys.argv[0])) + os.sep

Now it returns the following:

//

If i try following:
print str(sys.argv[0])

I receive:
-c

Is there any problem with last updates?

Thanks

Jorge

@riverfor
Copy link
Member

riverfor commented Mar 4, 2015

For some other reason, the script will be executed as the following way now :

python -c 'import site;exec(open("script path").read())'

But I will try to change it to the original way like "python <script path>" in future updates.

@riverfor
Copy link
Member

New version had fixed this issue,

Get it from http://www.pgyer.com/qpython

@jps1x2
Copy link
Author

jps1x2 commented Mar 27, 2015

Thanks for solving this issue!

Now when i run my script (i run it every few days without problems) i receive following error:

/data/data/com.hipipal.qpyplus/files/bin/qpython.sh /storage/emulated/0/com.hipipal.qpyplus/scripts/mmrUltSesFH.py && exit
lus/scripts/mmrUltSesFH.py && exit      <
Traceback (most recent call last):
  File "/storage/emulated/0/com.hipipal.qpyplus/scripts/mmrUltSesFH.py", line 8, in <module>
    import requests
ImportError: No module named requests
1|u0_a77@bqAquaris5HD:/ $

What is happening now?

Thanks!

@riverfor
Copy link
Member

Please install requests module with the pip_console.py from scripts.
2015年3月27日 下午10:50于 "jps1x2" notifications@github.com写道:

Thanks for solving this issue!

Now when i run my script (i run it every day without problems) i receive
following error:

/data/data/com.hipipal.qpyplus/files/bin/qpython.sh /storage/emulated/0/com.hipipal.qpyplus/scripts/mmrUltSesFH.py && exit
lus/scripts/mmrUltSesFH.py && exit <
Traceback (most recent call last):
File "/storage/emulated/0/com.hipipal.qpyplus/scripts/mmrUltSesFH.py", line 8, in
import requests
ImportError: No module named requests
1|u0_a77@bqAquaris5HD:/ $

I use every day this script to download from my running data.

Thanks!


Reply to this email directly or view it on GitHub
#48 (comment)
.

@jps1x2
Copy link
Author

jps1x2 commented Mar 27, 2015

I had installed this module, why i have to reinstall it?

I try the following command in pip console:

pip install requests --upgrade

And i receive very much errors like following ones:

-->pip install requests --upgrade
Downloading/unpacking requests
  Downloading requests-2.6.0.tar.gz (450Kb  Downloading requests-2.6.0.tar.gz ...
  Running setup.py egg_info for package requests
Installing collected packages: requests
  Found existing installation: requests 2.4.3
    Uninstalling requests:
Exception:
Traceback (most recent call last):
  File "/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/pip/basecommand.py", line 126, in main
    self.run(options, args)
  File "/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/pip/commands/install.py", line 228, in run
    requirement_set.install(install_options, global_options)
  File "/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/pip/req.py", line 1089, in install
    requirement.uninstall(auto_confirm=True)
  File "/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/pip/req.py", line 476, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/pip/req.py", line 1391, in remove
    renames(path, new_path)
  File "/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/pip/util.py", line 248, in renames
    shutil.move(old, new)
  File "/QPython/core/build/python-install/lib/python2.7/shutil.py", line 295, in move
  File "/QPython/core/build/python-install/lib/python2.7/shutil.py", line 205, in copytree
Error: [('/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/__init__.py', '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/__init__.py',
"[Errno 1] Operation not permitted: '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/__init__.py'"), ('/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/adapters.py', '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/adapters.py',
"[Errno 1] Operation not permitted: '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/adapters.py'"), ('/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/api.py', '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/api.py',
"[Errno 1] Operation not permitted: '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/api.py'"), ('/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/auth.py', '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/auth.py',
"[Errno 1] Operation not permitted: '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/auth.py'"), ('/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/certs.py', '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/certs.py',
"[Errno 1] Operation not permitted: '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/certs.py'"), ('/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/compat.py', '/storage/emulated/0/com.hipipal.qpyplus/cache/pip-NSVmPS-uninstall/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/requests-2.4.3-py2.7.egg/requests/compat.py', 
...
Storing complete log in /sdcard/com.hipipal.qpyplus/.pip/pip.log
-->

Before using my scripts several months ago i installed several modules (requests, pytz and others), Why now they are not in my system after last qpython update?

Thanks!

@jps1x2
Copy link
Author

jps1x2 commented Mar 27, 2015

Uninstalled completely qpython from my phone, deleted /sdcard/com.hipipal.qpyplus folder and reinstalled again qpython from play store.

Now following command from pip console:

pip install requests

Installs correctly this module but if i execute my script i receive again following error:

import requests
ImportError: No module named requests

But if i write following command in Qpython interactive console:

import requests

I don't receive errors and i can use module.

I don't understand it.

Thanks!

@riverfor
Copy link
Member

Can you post your script here or send to support@qpython.org ?

On Sat, Mar 28, 2015 at 12:20 AM, jps1x2 notifications@github.com wrote:

Uninstalled completely qpython from my phone, deleted
/sdcard/com.hipipal.qpyplus folder and reinstalled again qpython from play
store.

Now following command from pip console:

pip install requests

Installs correctly this module but if i execute my script i receive again
following error:

import requests
ImportError: No module named requests

But if i write following command in Qpython interactive console:

import requests

I don't receive errors and i can use module.

I don't understand it.

Thanks!


Reply to this email directly or view it on GitHub
#48 (comment)
.

river's showtime, river's game

@jps1x2
Copy link
Author

jps1x2 commented Mar 29, 2015

Following one-line script was not working for me:

import requests

Now i uninstalled again completely Qpython (deleted app cache, app data and app uninstall) and after reinstalling if i try to open console i receive following errors:

/data/data/com.hipipal.qpyplus/files/bin/qpython.sh && exit
us/files/bin/qpython.sh && exit         <
Python 2.7.2 (default, Oct 25 2014, 20:52:15)
[GCC 4.9 20140827 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Could not open PYTHONSTARTUP
IOError: [Errno 2] No such file or directory: '/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/qpythoninit.py'
>>>

Is there any way to delete completely Qpython and reinstall it again to install all needed files?

How could i install previous QPython version and use it until all this problems are solved?

Thanks!

@jps1x2
Copy link
Author

jps1x2 commented Mar 29, 2015

Downloaded version 1.0.2 from http://www.pgyer.com/qpython and installed again.

Executed from pip console following commands:

pip install requests
pip install python-dateutil
pip install dropbox

Now my scripts are working perfect again.

Thanks!

@riverfor
Copy link
Member

Nice to know that. : )

And You can create a new file which contains the "import site" as
/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/qpythoninit.py
to solve the previous error

IOError: [Errno 2] No such file or directory:

"/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/qpythoninit.py"

Thanks.

On Mon, Mar 30, 2015 at 7:33 AM, jps1x2 notifications@github.com wrote:

Downloaded version 1.0.2 from http://www.pgyer.com/qpython and installed
again.

Executed from pip console following commands:

pip install requests
pip install python-dateutil
pip install dropbox

Now my scripts are working perfect again.

Thanks!


Reply to this email directly or view it on GitHub
#48 (comment)
.

river's showtime, river's game

@jps1x2
Copy link
Author

jps1x2 commented Mar 31, 2015

Hi,

i have updated via Play Store to version 1.0.6 and i have the same problem:

.qpyplus/scripts/.last_tmp.py && exit   <
Traceback (most recent call last):
  File "/storage/emulated/legacy/com.hipipal.qpyplus/scripts/.last_tmp.py", line 1, in <module>
    import requests
ImportError: No module named requests
1|u0_a115@bqAquaris5HD:/ $

When executing following script:

import requests
print 'test'

In this version file /storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/qpythoninit.py exists with following content:

import site

Now i don't receive error:

IOError: [Errno 2] No such file or directory:
"/storage/emulated/0/com.hipipal.qpyplus/lib/python2.7/site-packages/qpythoninit.py"

In console i can import this module without problems and use it:

/data/data/com.hipipal.qpyplus/files/bin/qpython.sh && exit
us/files/bin/qpython.sh && exit         <
Python 2.7.2 (default, Oct 25 2014, 20:52:15)
[GCC 4.9 20140827 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.packages.urllib3.disable_warnings()
>>>

Thanks!

@jps1x2
Copy link
Author

jps1x2 commented Jun 14, 2015

Any news on my problem?

I can't use version 1.0.6 and I have to use old 1.0.2 version. I receive daily messages from play store to update to last version (1.0.6) on market.

I would like to install last version and run my scripts.

Thanks in advance!

@riverfor
Copy link
Member

I will work on it tomorrow.

Thanks.

On Sun, Jun 14, 2015 at 11:39 AM, jps1x2 notifications@github.com wrote:

Any news on my problem?

I can't use version 1.0.6 and I have to use old 1.0.2 version. I receive
daily messages from play store to update to last version (1.0.6) on market.

I would like to install last version and run my scripts.

Thanks in advance!


Reply to this email directly or view it on GitHub
#48 (comment)
.

river's showtime, river's game

@XIVN1987
Copy link

i have the same problem, the QPython i used is version 1.1.1
and my temporary solution is add the following statements in my script:
if True: #Android QPython
os.chdir(os.path.dirname(file))
sys.path.append('/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/websocket_server-0.4-py2.7.egg')
sys.path.append('/data/data/com.hipipal.qpyplus/files/lib/python2.7/site-packages/CherryPy-3.8.0-py2.7.egg')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants