Can't import numpy in Texgen

General discussion about TexGen.

Moderators: Martin, Developers

Post Reply
bluezoe
Regular
Posts: 13
Joined: Tue Aug 20, 2019 2:38 am

Can't import numpy in Texgen

Post by bluezoe »

Hello,
I imported numpy and scipy library to calculate the points needed for function CSectionPolygon. This was working well in my Spyder(open source scientific environment written in Python). However when I run my script in TexGen, there was error'' ImportError: No module named numpy''. How can I figure this?
Thanks.
Zoe
louisepb
Project Leader
Posts: 998
Joined: Tue Dec 08, 2009 2:27 pm
Location: Nottingham

Re: Can't import numpy in Texgen

Post by louisepb »

Hi Zoe,

My guess is that this is a path issue. In Spyder it will be set up to know where to find the NumPy module. You probably need to add the folder which includes the NumPy module to your path so that it can be found from wherever you have TexGen installed.

Hope that helps,
Louise
bluezoe
Regular
Posts: 13
Joined: Tue Aug 20, 2019 2:38 am

Re: Can't import numpy in Texgen

Post by bluezoe »

Hello,

After adding the path, there was a new problem.

Code: Select all

import sys
sys.path.append('C:\\Users\\zoe\\Anaconda3\\Lib\\site-packages')
It shows:

Code: Select all

Traceback (most recent call last):
  File "gui", line 1, in <module>
  File "C:\Users\zoe\Desktop\temp.py", line 13, in <module>
    import numpy as np
  File "C:\Users\zoe\Anaconda3\Lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\zoe\Anaconda3\Lib\site-packages\numpy\_distributor_init.py", line 33, in <module>
    with RTLD_for_MKL():
  File "C:\Users\zoe\Anaconda3\Lib\site-packages\numpy\_distributor_init.py", line 18, in __enter__
    import ctypes
ImportError: No module named ctypes
How can I figure this in texgen?

Thanks.
bluezoe
Regular
Posts: 13
Joined: Tue Aug 20, 2019 2:38 am

Re: Can't import numpy in Texgen

Post by bluezoe »

Hello,

I have figured this question by re-load a Texgen and python installation package rather than a python-bundled version,
Then I pip the numpy packages under the Python.

Thanks for your advice.
Zoe.
Post Reply