TinkerBoard / gpio_lib_python

MIT License
40 stars 19 forks source link

Import issue #2

Open aklofas opened 6 years ago

aklofas commented 6 years ago

Follow steps: 1) python3 setup.py install 2) No issues on compile/install 3) >>> import ASUS.GPIO Traceback (most recent call last): File "", line 1, in ImportError: No module named 'ASUS.GPIO'

Same output using python2.7 as well.

rbuffat commented 6 years ago

This message indicates that the module ASUS.GPIO is not installed. Can you post the output of sudo python3 setup.py install

farzadsw commented 6 years ago

I have same problem. this is out put of setup.py: linaro@tinkerboard:~/gpio_lib_python$ sudo python3 setup.py install running install running build running build_py creating build creating build/lib.linux-armv7l-3.5 creating build/lib.linux-armv7l-3.5/ASUS copying ASUS/init.py -> build/lib.linux-armv7l-3.5/ASUS running build_ext building 'ASUS.GPIO' extension creating build/temp.linux-armv7l-3.5 creating build/temp.linux-armv7l-3.5/source arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/py_gpio.c -o build/temp.linux-armv7l-3.5/source/py_gpio.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/c_gpio.c -o build/temp.linux-armv7l-3.5/source/c_gpio.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/cpuinfo.c -o build/temp.linux-armv7l-3.5/source/cpuinfo.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/event_gpio.c -o build/temp.linux-armv7l-3.5/source/event_gpio.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/soft_pwm.c -o build/temp.linux-armv7l-3.5/source/soft_pwm.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/py_pwm.c -o build/temp.linux-armv7l-3.5/source/py_pwm.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/common.c -o build/temp.linux-armv7l-3.5/source/common.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/constants.c -o build/temp.linux-armv7l-3.5/source/constants.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/wiringTB.c -o build/temp.linux-armv7l-3.5/source/wiringTB.o arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-armv7l-3.5/source/py_gpio.o build/temp.linux-armv7l-3.5/source/c_gpio.o build/temp.linux-armv7l-3.5/source/cpuinfo.o build/temp.linux-armv7l-3.5/source/event_gpio.o build/temp.linux-armv7l-3.5/source/soft_pwm.o build/temp.linux-armv7l-3.5/source/py_pwm.o build/temp.linux-armv7l-3.5/source/common.o build/temp.linux-armv7l-3.5/source/constants.o build/temp.linux-armv7l-3.5/source/wiringTB.o -o build/lib.linux-armv7l-3.5/ASUS/GPIO.cpython-35m-arm-linux-gnueabihf.so running install_lib creating /usr/local/lib/python3.5/dist-packages/ASUS copying build/lib.linux-armv7l-3.5/ASUS/init.py -> /usr/local/lib/python3.5/dist-packages/ASUS copying build/lib.linux-armv7l-3.5/ASUS/GPIO.cpython-35m-arm-linux-gnueabihf.so -> /usr/local/lib/python3.5/dist-packages/ASUS byte-compiling /usr/local/lib/python3.5/dist-packages/ASUS/init.py to init.cpython-35.pyc running install_egg_info Writing /usr/local/lib/python3.5/dist-packages/ASUS.GPIO-0.1.egg-info running install running build running build_py creating build/lib.linux-armv7l-3.5/RPi copying RPi/init.py -> build/lib.linux-armv7l-3.5/RPi running build_ext building 'RPi.GPIO' extension arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/py_gpio_RPi.c -o build/temp.linux-armv7l-3.5/source/py_gpio_RPi.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/c_gpio.c -o build/temp.linux-armv7l-3.5/source/c_gpio.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/cpuinfo.c -o build/temp.linux-armv7l-3.5/source/cpuinfo.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/event_gpio.c -o build/temp.linux-armv7l-3.5/source/event_gpio.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/soft_pwm.c -o build/temp.linux-armv7l-3.5/source/soft_pwm.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/py_pwm.c -o build/temp.linux-armv7l-3.5/source/py_pwm.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/common.c -o build/temp.linux-armv7l-3.5/source/common.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/constants.c -o build/temp.linux-armv7l-3.5/source/constants.o arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c source/wiringTB.c -o build/temp.linux-armv7l-3.5/source/wiringTB.o arm-linux-gnueabihf-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,relro -g -fdebug-prefix-map=/build/python3.5-haFsHd/python3.5-3.5.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-armv7l-3.5/source/py_gpio_RPi.o build/temp.linux-armv7l-3.5/source/c_gpio.o build/temp.linux-armv7l-3.5/source/cpuinfo.o build/temp.linux-armv7l-3.5/source/event_gpio.o build/temp.linux-armv7l-3.5/source/soft_pwm.o build/temp.linux-armv7l-3.5/source/py_pwm.o build/temp.linux-armv7l-3.5/source/common.o build/temp.linux-armv7l-3.5/source/constants.o build/temp.linux-armv7l-3.5/source/wiringTB.o -o build/lib.linux-armv7l-3.5/RPi/GPIO.cpython-35m-arm-linux-gnueabihf.so running install_lib creating /usr/local/lib/python3.5/dist-packages/RPi copying build/lib.linux-armv7l-3.5/RPi/init.py -> /usr/local/lib/python3.5/dist-packages/RPi copying build/lib.linux-armv7l-3.5/RPi/GPIO.cpython-35m-arm-linux-gnueabihf.so -> /usr/local/lib/python3.5/dist-packages/RPi byte-compiling /usr/local/lib/python3.5/dist-packages/RPi/init.py to init.cpython-35.pyc running install_egg_info Writing /usr/local/lib/python3.5/dist-packages/RPi.GPIO-0.1.egg-info

farzadsw commented 6 years ago

I checked the build directory, the module is created . After I manually copied the module file to my path it worked. So i guess the install script needs to be fixed.

scorpiochang commented 6 years ago

Hi farzadsw

i just install gpio_lib_python and run test program. i don't observe any error message. can i know what program you can't execute before you copy module files? thank you.

cr1901 commented 4 years ago

This is an old issue, but might as well respond with what worked for me:

If you try to import ASUS.GPIO from within the gpio_lib_python source directory root, python will think the module you want to import is at the wrong place:

wjones@DietPi:~/src/tinker/gpio_lib_python$ python3 -c 'import ASUS; print(ASUS.__path__)'
['/home/wjones/src/tinker/gpio_lib_python/ASUS']
wjones@DietPi:~/src/tinker/gpio_lib_python$ python3 -c 'import ASUS.GPIO'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ASUS.GPIO'

Outside of the source directory, however, python will pick up the correct module if you've ran setup.py install, and import ASUS.GPIO will succeed:

wjones@DietPi:~/src/tinker$ python3 -c 'import ASUS; print(ASUS.__path__)'
['/usr/local/lib/python3.7/dist-packages/ASUS']
wjones@DietPi:~/src/tinker$ python3 -c 'import ASUS.GPIO'
wjones@DietPi:~/src/tinker$

Solution for me was to _not test the library from within the gpio_lib_python directory_.

ZongXR commented 8 months ago

This is an old issue, but might as well respond with what worked for me:

If you try to import ASUS.GPIO from within the gpio_lib_python source directory root, python will think the module you want to import is at the wrong place:

wjones@DietPi:~/src/tinker/gpio_lib_python$ python3 -c 'import ASUS; print(ASUS.__path__)'
['/home/wjones/src/tinker/gpio_lib_python/ASUS']
wjones@DietPi:~/src/tinker/gpio_lib_python$ python3 -c 'import ASUS.GPIO'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ASUS.GPIO'

Outside of the source directory, however, python will pick up the correct module if you've ran setup.py install, and import ASUS.GPIO will succeed:

wjones@DietPi:~/src/tinker$ python3 -c 'import ASUS; print(ASUS.__path__)'
['/usr/local/lib/python3.7/dist-packages/ASUS']
wjones@DietPi:~/src/tinker$ python3 -c 'import ASUS.GPIO'
wjones@DietPi:~/src/tinker$

Solution for me was to _not test the library from within the gpio_lib_python directory_.

Great! That's usefule for me. Thank you very much.

Baiokis commented 8 months ago

I have the same problem, someone can help me?

Traceback (most recent call last): File "c:\Users\alexa\OneDrive\Documentos\BM Tech\TinkerBoard\gpio_lib_python\test\GPIO_IN_OUT_test.py", line 2, in import ASUS.GPIO as GPIO ModuleNotFoundError: No module named 'ASUS'

I already install every dependence and others packages

ZongXR commented 7 months ago

I have the same problem, someone can help me?

Traceback (most recent call last): File "c:\Users\alexa\OneDrive\Documentos\BM Tech\TinkerBoard\gpio_lib_python\test\GPIO_IN_OUT_test.py", line 2, in import ASUS.GPIO as GPIO ModuleNotFoundError: No module named 'ASUS'

I already install every dependence and others packages

You should manually modify setup.py. Retain just one setup function and delete another. And then install like this. sudo python setup.py install # for python2 sudo pip3 install . # for python3, and notice the dot at the end I tried this successfully