Python Forum

Full Version: ImportError: cannot import name 'Union' from '_ctypes' (unknown location)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
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 ?
no news ?
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
There are no binary for Solaris 10 and my server have no access to Internet
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
thank you to all but my problem is not compile the Python 3.8.5.

the my problem is how to add the modules.
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
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
you can use locate syntax locate modulename
or find find . -name modulename

both may require a 'sudo' prefix
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 ?
Pages: 1 2