← Back to team overview

yade-users team mailing list archive

Re: [Question #685892]: Importing Yade in other Python applications

 

Question #685892 on Yade changed:
https://answers.launchpad.net/yade/+question/685892

    Status: Open => Answered

William Chevremont proposed the following answer:
Hi,

Did you compile yade using python3 version?

According to this line :

  print 'Yade version: %s%s'%(version,debugbuild)

it seems not.

William

On 15/11/2019 11:03, Rong Zhao wrote:
> New question #685892 on Yade:
> https://answers.launchpad.net/yade/+question/685892
>
> Hi, I have a problem with importing Yade in other Python applications. The Yade documentation provides the easiest way to import the Yade in other Python applications.  I try the provided method to create a symbolic link as explained below.
>
> =================================================================================
> $ cd /home/zhaorong/Desktop/
> $ ln -s /home/zhaorong/myYade/build/bins/yade-2019.01a /home/zhaorong/Desktop/yadeimport.py
> =================================================================================
>
> Then, I tried in Python2 and it succeeded.
> ======================================================
> zhaorong@ubuntu64:~/Desktop$ python2
> Python 2.7.16 (default, Oct  7 2019, 17:36:04)
> [GCC 8.3.0] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys
>>>> sys.path.append('/home/zhaorong/Desktop/')
>>>> from yadeimport import *
> =======================================================
>
> But when I used the same method in python3, it failed.
> =======================================================
> zhaorong@ubuntu64:~/Desktop$ python3
> Python 3.7.3 (default, Oct  7 2019, 12:56:13)
> [GCC 8.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import sys
>>>> sys.path.append('/home/zhaorong/Desktop/')
>>>> from yadeimport import *
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
>    File "/home/zhaorong/Desktop/yadeimport.py", line 71
>      print 'Yade version: %s%s'%(version,debugbuild)
>                               ^
> SyntaxError: invalid syntax
> =======================================================
>
> I want to know whether the Yade is imported to Python2 applications only, not  Python3 applications.
>
> Thanks.
>
>

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.