Python Forum
ImportError: cannot import name 'Union' from '_ctypes' (unknown location)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ImportError: cannot import name 'Union' from '_ctypes' (unknown location)
#1
I have compiled Python 3.8.5 and tested ok, I am on Solaris 10 system

now I need to add some modules but I get these errors

root@ssc50005:/sun-temp/pysftp-0.2.9$ LD_LIBRARY_PATH=/usr/lib:/usr/local/lib
root@ssc50005:/sun-temp/pysftp-0.2.9$ export LD_LIBRARY_PATH

root@ssc50005:/sun-temp/pysftp-0.2.9$ /usr/local/Python-3.8.5/python setup.py install
Traceback (most recent call last):
File "setup.py", line 3, in <module>
from setuptools import setup
ModuleNotFoundError: No module named 'setuptools'

and also:

root@ssc50005:/sun-temp/setuptools-50.3.0$ /usr/local/Python-3.8.5/python setup.py install
['/sun-temp/setuptools-50.3.0', '/usr/local/lib/python38.zip', '/usr/local/Python-3.8.5/Lib', '/usr/local/Python-3.8.5/build/lib.solaris-2.10-sun4u.32bit-3.8']
Traceback (most recent call last):
File "setup.py", line 11, in <module>
import _ctypes
ModuleNotFoundError: No module named '_ctypes'

but this module is present:

root@ssc50005:/sun-temp/setuptools-50.3.0$ find /usr/local/Python-3.8.5/ -name _ctypes*
/usr/local/Python-3.8.5/PCbuild/_ctypes_test.vcxproj.filters
/usr/local/Python-3.8.5/PCbuild/_ctypes.vcxproj.filters
/usr/local/Python-3.8.5/PCbuild/_ctypes.vcxproj
/usr/local/Python-3.8.5/PCbuild/_ctypes_test.vcxproj
/usr/local/Python-3.8.5/build/lib.solaris-2.10-sun4u.32bit-3.8/_ctypes_test.so
/usr/local/Python-3.8.5/build/temp.solaris-2.10-sun4u.32bit-3.8/presidio_sun/SUNFREEWARE/python/Python-3.8.5/Modules/_ctypes
/usr/local/Python-3.8.5/build/temp.solaris-2.10-sun4u.32bit-3.8/presidio_sun/SUNFREEWARE/python/Python-3.8.5/Modules/_ctypes/_ctypes_test.o
/usr/local/Python-3.8.5/Modules/_ctypes
/usr/local/Python-3.8.5/Modules/_ctypes/_ctypes_test.c
/usr/local/Python-3.8.5/Modules/_ctypes/_ctypes_test.h
/usr/local/Python-3.8.5/Modules/_ctypes/_ctypes.c

so how to set path on python ?

using PYTHONPATH to /usr/local/Python-3.8.5/Modules ?
Reply
#2
no news ?
Reply
#3
why are you compiling python, there are ready made binary installs here: https://www.python.org/downloads/
once you install from here you can add packages with pip install packagename
Reply
#4
There are no binary for Solaris 10 and my server have no access to Internet
Reply
#5
Understood, but I'm scratching my head, I haven't been without internet since there was no web and only archie and gopher.
There is this site which may proove useful: http://www.dbaglobe.com/2017/12/install-...thout.html
Reply
#6
thank you to all but my problem is not compile the Python 3.8.5.

the my problem is how to add the modules.
Reply
#7
I'm not sure if this will work, but it's worth a try.

First install all of the packages that you need on a computer with internet access, using pip
  • All of the following on computer with internet:
    • create a virtual environment In a new directory, using python 3.8.5 with python -m venv venv
    • activate the virtual environment with command: . ./venv/bin/acctivate
    • Upgrade pip to eliminate annoying warnings: pip install --upgrade pip
    • check to see if the packages are already installed on the internet computer with pip list
    • download missing packages with pip install packagename
    • copy all missing (only) packages from venv/lib/python3.8/site-packages to thumb drive in a lib/site_packages directory.
    • Do the same for venv/lib64/python3.8/site-packages and save on thumb drive lib64/site_packages directory.
    • libraries have to be installed with yum, or apt-get (depending on your distro, can check with which yum or which apt
    • for these libraries, first see if they are already installed,
      look in /usr/share/doc/ if there, create a user/share/doc directory (on thumb drive) and copy there
    • if not there install (preferable to use synaptic package manager, but you can also use: sudo apt-get install libffi-dev
      do the same for all libraries and then copy to thumb drive
    • deactivate
    • remove venv diretory you created earlier.
  • on computer with out internet:
    • copy libaries from thumb drive to /usr/share/doc/ (use sudo)
    • copy pip files to venv/lib/python3.8/site-packages and venv/lib64/python3.8/site-packages respectively.

Edited 9:02 PM DST Forgot important step
Reply
#8
sorry Larz but could you more clear about the offline steps ?

I have these 3 directories

drwxr-xr-x 18 1000 1000 1024 Sep 11 16:16 Python-3.8.5 <<< where I have compiled the Python
drwxrwxr-x 5 1000 1000 1024 Jul 6 2016 pysftp-0.2.9 <<< module to install
drwxr-xr-x 7 root root 1024 Sep 5 15:27 setuptools-50.3.0 <<< probably a module necessary

ls pysftp-0.2.9
LICENSE.txt PKG-INFO docs pysftp.egg-info setup.cfg
MANIFEST.in README.rst pysftp requirements-dev.txt setup.py

I see now at the end of compile steps there are these messages:

Python build finished successfully!
The necessary bits to build these optional modules were not found:
_gdbm _lzma ossaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.


The following modules found by detect_modules() in setup.py, have been
built by the Makefile instead, as configured by the Setup files:
_abc atexit pwd
time


Failed to build these modules:
_ctypes


Following modules built successfully but were removed because they could not be imported:
_curses _curses_panel
Reply
#9
you can use locate syntax locate modulename
or find find . -name modulename

both may require a 'sudo' prefix
Reply
#10
find . -name _ctypes
./Modules/_ctypes
./build/temp.solaris-2.10-sun4u.32bit-3.8/presidio_sun/SUNFREEWARE/python/Python-3.8.5/Modules/_ctypes

Have you seen the errors in the compile phase ?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Cannot import easysnmp: ImportError: libnetsnmp.so.30 Calab 4 1,057 Jun-08-2023, 08:52 PM
Last Post: Gribouillis
  ImportError: cannot import name 'Pyfhel' from 'Pyfhel' Anldra12 9 3,573 Dec-13-2021, 06:55 PM
Last Post: Anldra12
  ImportError: cannot import name 'get_config' russray2008 0 4,759 Sep-20-2021, 02:18 PM
Last Post: russray2008
  Inheritance vs Union gserranowong 3 2,250 Jun-29-2021, 06:13 PM
Last Post: gserranowong
  ImportError: cannot import name 'Request' from 'request' abhishek81py 1 3,945 Jun-18-2020, 08:07 AM
Last Post: buran
  ImportError: cannot import name 'MidiEvaluator' from 'parser' (Windows 10) spiffspaceman 4 2,696 May-22-2020, 10:16 PM
Last Post: snippsat
  ImportError: cannot import name 'X ' from ' Y' (Unknown location) Arjunpi 1 4,367 Apr-30-2020, 12:56 AM
Last Post: Larz60+
  Lists union and intersecion arbiel 5 2,848 Mar-28-2020, 05:57 AM
Last Post: buran
  Where could I get _ctypes module except libffi-dev? Snake 7 8,296 Jan-17-2020, 11:10 AM
Last Post: Larz60+
  problem with mapnik in anaconda python 2: from _mapnik import * ImportError: DLL load parsley 0 1,911 Dec-11-2019, 07:50 AM
Last Post: parsley

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020