-
Notifications
You must be signed in to change notification settings - Fork 3
peforth says 'file not found' on Ubuntu
The site
module provides site.PREFIXES that is the key information I need to fix this problem. See __init_.py
.
After pip3 install peforth
if peforth makes "file not found"
error on your Ubuntu, the solution is: manually copy all files in ~/.local/lib/site-packages/peforth
to ~/.local/lib/python3.5/site-packages/peforth
then it will work. Do this again for an upgrade.
On Windows 10 after pip install peforth
the package of 7 files (so far) are all in one folder :
Volume in drive C is Windows
Volume Serial Number is ACE4-3690
Directory of c:\Users\hcche\AppData\Local\Programs\Python\Python36\Lib\site-packages\peforth
2017-10-11 08:32 63,728 peforth.f
2017-10-09 09:49 20,715 peforth.selftest
2017-09-25 09:38 20,392 projectk.py
2017-10-11 10:08 6,202 quit.f
2017-10-11 11:24 20 version.txt
2017-10-11 12:14 4,443 __init__.py
2017-10-09 09:49 233 __main__.py
On Ubuntu Linux, they appear in different folders:
.py files are in ~/.local/lib/python3.5/site-packages/peforth
__init__.py __main__.py projectk.py
other files are in ~/.local/lib/site-packages/peforth
peforth.f peforth.selftest quit.f version.txt
that makes a file not found
problem because __init__.py
expects data files at the same folder where it is. I didn't find an acceptable solution but a workaround which is simply to manually copy all files in ~/.local/lib/site-packages/peforth
to ~/.local/lib/python3.5/site-packages/peforth
then peforth will work fine.
None of the below findings work, either don't they meet the needs of peforth or that I can't handle the correct path things of Linux. Anyone know of the correct method to get the two paths please let me know or modify the init.py directly for Ubuntu or other Linux.
OK py:~ import distutils.sysconfig as config; push(config)
OK constant config
OK config dir . cr
['BASE_EXEC_PREFIX', 'BASE_PREFIX', 'DistutilsPlatformError', 'EXEC_PREFIX', 'PREFIX', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_config_vars', '_findvar1_rx', '_findvar2_rx', '_imp', '_init_nt', '_init_posix', '_is_python_source_dir', '_python_build', '_sys_home', '_variable_rx', 'build_flags', 'customize_compiler', 'expand_makefile_vars',
'get_config_h_filename', 'get_config_var', 'get_config_vars', 'get_makefile_filename', 'get_python_inc', 'get_python_lib', 'get_python_version', 'os', 'parse_config_h', 'parse_makefile', 'project_base', 'python_build', 're', 'sys']
OK
from distutils.sysconfig import get_python_lib>>> print(get_python_lib())
It will get you both dist-packages and site-packages folders. If the folder is not on Python's path, it won't be doing you much good anyway.
import sys; print [f for f in sys.path if f.endswith('packages')]
Output (Ubuntu installation):
['/home/username/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']
https://stackoverflow.com/questions/779495/python-access-data-in-package-subdirectory
https://askubuntu.com/questions/262063/how-to-find-python-installation-directory-on-ubuntu