Skip to content
This repository has been archived by the owner on Mar 14, 2018. It is now read-only.

[Fixed 2015-10-25] importing python modules doesn't seem to work anymore #155

Open
clintmod opened this issue Aug 6, 2015 · 16 comments
Open
Assignees
Labels

Comments

@clintmod
Copy link

clintmod commented Aug 6, 2015

I'm running a nightly build 2014-12-17_01:01nightly and importing python modules works as one would expect but when I tried the latest GA release it's unable to resolve the module location.

My environment is Windows 7 64 bit with java 1.7 running from both the script runner and sikuli IDE

Here's a small example of the problem.
https://www.dropbox.com/s/x4zqrhf3n196xd3/module_example.zip?dl=0

The dir structure looks like:
module_example

  • main.sikuli
    • main.py
  • asdf.py
  • common
    • init.py
    • module1.py

The older build from december is able to import both modules but the latest build throws:
[error] script [ main ] stopped with error in line 1
[error] ImportError ( No module named asdf )

main.py looks like this:

import asdf
from common.module1 import print_from_module_1
print "this is the main module"
print_from_module_1()
print asdf.asdf_method()

@clintmod
Copy link
Author

clintmod commented Aug 6, 2015

Seems related to this: ImportError (module.sikuli has no module.py)

@RaiMan
Copy link
Owner

RaiMan commented Aug 9, 2015

ok, I will check next week, when I am back from vacation ;-)

@RaiMan RaiMan added the bug label Oct 25, 2015
@RaiMan RaiMan added this to the bug fix release 1.1.1 milestone Oct 25, 2015
@RaiMan RaiMan self-assigned this Oct 25, 2015
@RaiMan RaiMan changed the title importing python modules doesn't seem to work in the latest build [Fixed 2015-10-25] importing python modules doesn't seem to work anymore Oct 25, 2015
@RaiMan
Copy link
Owner

RaiMan commented Oct 25, 2015

Should work with the nightly build 1.1.1 (when available)

@RaiMan RaiMan closed this as completed Oct 25, 2015
RaiMan pushed a commit that referenced this issue Oct 25, 2015
@RaiMan
Copy link
Owner

RaiMan commented Oct 25, 2015

fix: 4a6bc67

@RaiMan
Copy link
Owner

RaiMan commented Oct 25, 2015

just to leave it in the list

@RaiMan RaiMan reopened this Oct 25, 2015
@DavidPerezIngeniero
Copy link

DavidPerezIngeniero commented May 16, 2017

I have this:

  • main.py
  • common.py

and from main.py I do:

from common import *

and it works when launching by hitting the Run button.
But when launching from the command line, it fails:

[error] ImportError ( No module named common )

Using SikuliX 1.1.1. under Linux.

@DavidPerezIngeniero
Copy link

I've tried to do:

import sys
sys.append('/absolute/path/to/container/of/common.py')

and it keeps failing.

@RaiMan
Copy link
Owner

RaiMan commented May 16, 2017

how do you run from commandline?

@DavidPerezIngeniero
Copy link

DavidPerezIngeniero commented May 16, 2017

Thanks for your response RaiMan. :-)

runsikulix -c -r ../TestQR.sikuli/ --args myarg

@DavidPerezIngeniero
Copy link

DavidPerezIngeniero commented May 16, 2017

Solved, it didn't work before, because I've put sys.path.append() after import common.
Why the current directory is in sys.path when running from the IDE, whereas isn't when running from the command line?

@RaiMan
Copy link
Owner

RaiMan commented May 16, 2017

Without having checked accurately:

../TestQR.sikuli/

paths with ../.... are not supported as current directory in sys.path - go to the folder containing TestQR.sikuli and use

somePath/runsikulix -c -r TestQR.sikuli --args myarg

@DavidPerezIngeniero
Copy link

In sys.path, I only use absolute paths.

@RaiMan
Copy link
Owner

RaiMan commented May 17, 2017

Yes, I have seen it.

missunderstanding, sorry: I meant, that the use of ../TestQR.sikuli/ on the commandline might lead internally to a wrong entry in sys.path, that is added by SikuliX automatically.

I will check that.

@JoelJoy58
Copy link

i am trying to import openpyxl in sikulix 1.1.0

import openpyxl

i am getting error as:
[error] script [ Untitled ] stopped with error in line 1
[error] ImportError ( No module named base )

inside the sikulix lib folder i have create a folder site-packages, sites.txt file with the path to my python lib files to access the python library which i have installed. other function like xlsxwriter,pyodbc, etc. are working without error.
please help me out

C:\Users\10612159\AppData\Roaming\Sikulix\Lib\site-packages
sites.txt - C:\Program Files (x86)\Python36-32\Lib\site-packages\

@RaiMan
Copy link
Owner

RaiMan commented Sep 25, 2017

@JoelJoy58
it seems that openpyxl is not coded only in Python language, but contains or depends on C-based stuff. If this is true, it cannot be used with Jython (Java based).

@JoelJoy58
Copy link

@RaiMan
Thank you so much :)

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

No branches or pull requests

4 participants