Python: libpython3.5.dylib not found? - python

I would like to make a Mac executable for my Python code but always got this error message:
OSError: Python library not found: .Python, libpython3.5.dylib, Python
Both PyInstaller and py2app returned the same error. What should I do to overcome this problem?

For Mac, try rebuild python to generated shared lib using:
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.5.x
as said in pyenv offical doc
in which 3.5.x is version of python which you are using
For my here, after reinstall python:
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.8.0
the dylib located in
~/.pyenv/versions/3.8.0/Python.framework/Versions/3.8/lib/libpython3.8.dylib
which is soft link to 3.4MB file:
~/.pyenv/versions/3.8.0/Python.framework/Versions/3.8/Python

Related

How to find Python 3's home and dll path installed by pyenv on Ubuntu?

When use vim's insert mode, it happened:
/home/user/.vim/plugged/ultisnips/autoload/UltiSnips.vim Error:
E319: Sorry, can't use: py3 import vim
Because now using this plugin:
Plug 'SirVer/ultisnips'
I installed Python3 by pyenv.
$ pyenv versions
system
* 3.9.1 (set by /home/user/.pyenv/version)
$ which python
/home/user/.pyenv/shims/python
$ python -V
Python 3.9.1
When use macOS, set these items into ~/.vimrc can resolve the problem:
set pythonthreedll=/usr/local/Frameworks/Python.framework/Versions/3.9/Python
set pythonthreehome=/usr/local/Frameworks/Python.framework/Versions/3.9
But on Ubuntu, how to find pythongthreehome and pythonthreedll path? I tried to set /home/user/.pyenv/shims/python, not work.
The problem is most likely that you have a Vim package without Python enabled.
You can tell that from the vim --version output (or :version inside Vim.) If it says +python3 or +python3/dyn, then it means Python is enabled. On the other hand, if it says -python3, then it doesn't.
If your Vim has Python disabled, you will need to install a different Vim package. On Ubuntu or Debian, you could use apt-get install vim-nox to install a Vim package which has Python enabled.

python3 --version command not returning correct version

I am trying to upgrade to the most recent version of python, which is currently 3.8.5.
When I type python3 --version, I get:
Python 3.7.0
So it appears my python is not up-to-date. I then type brew upgrade python and get a warning:
Warning: python 3.8.5 already installed
So, again, I type python3 --version, and again I get:
Python 3.7.0
Why is python3 --version not returning Python 3.8.5?
(PS - if I type python --version I get Python 2.7.11 as expected for my Mac)
Homebrew is installing python 3.8.5 to a different path. Try:
brew link python3
brew update
brew upgrade python3
brew cleanup python3
You may have multiple python binaries on your system but the system path is finding 3.7.0. The command which python3 will show the path of your current python binary.
It might be worthwhile taking a look at the system path with echo $PATH to see where your system is looking for Python
Updating your system environment using export as below should enable the system to find python3.8.5
PATH="/path/to/python3.8.5/bin:${PATH}"
export PATH

Error loading Python lib with PyInstaller on MacOS

I am trying to package some python into an executable on MacOS (10.14.5). I am able to create the executable, but executing the resulting dist/hello_world executable gives the following error:
[55240] Error loading Python lib '/var/folders/yh/6_6mb2y96kg0gnb_nh9r2zrr0000gp/T/_MEIwUMw4X/Python': dlopen: dlopen(/var/folders/yh/6_6mb2y96kg0gnb_nh9r2zrr0000gp/T/_MEIwUMw4X/Python, 10): no suitable image found. Did find:
/var/folders/yh/6_6mb2y96kg0gnb_nh9r2zrr0000gp/T/_MEIwUMw4X/Python: code signature invalid for '/var/folders/yh/6_6mb2y96kg0gnb_nh9r2zrr0000gp/T/_MEIwUMw4X/Python'
My machine is running Python 3.7.7 installed from using the Mac installer downloaded from https://www.python.org/
For now, the script I am trying to package only contains print('hello world!') and the packaging command I am using is pyinstaller -F hello_world.py
I had success using pyenv and installing the specific version of python with the enable framework option:
env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.7.6
With this version of python (set using the command pyenv local 3.7.6 in the folder where hello_world.py is located), install pyinstaller (and any other modules you need) with pip. Then build with
pyinstaller hello_world.py --onefile --clean --windowed
which should give you a functioning dist/hello_word. As a python fledgling, I have no idea why this works as opposed to the steps in the original question. (I thought the Mac OS installer included the Python.framework by default -- I'm sure my ignorance is exposed here as this probably differs significantly from what the PYTHON_CONFIGURE_OPTS variable is doing above).
Also possible to do all this within a virtual environment (easily managed by pyenv-virtualenv).
The latest version of Pyinstaller only supports Python 2.7, 3.5–3.7. If you downgrade to Python 3.7 it will work!

sphinx_rtd_theme is no longer a hard dependency since version 1.4.0

C:\Users\Administrator\Desktop\item\code_serv\documents\api>make html
Running Sphinx v1.6.2 loading pickled environment... failed:
Can't get attribute 'WarningStream' on <module 'sphinx.util.nodes' from 'c:\\users\\administrator\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\sphinx\\util\\nodes.py'>
Theme error:
sphinx_rtd_theme is no longer a hard dependency since version 1.4.0.
Please install it manually.(pip install sphinx_rtd_theme)
How do I solve this?
I found another issue, I had two installations of sphinx, one via pip and another one via brew. Deleting one (I chose to remove installation done via brew ) solved this issue.
brew remove sphinx-doc
If it still doesnt work, try uninstalling and reinstalling
pip3 uninstall sphinx sphinx_rtd_theme
pip3 install sphinx sphinx_rtd_theme
Your question does not indicate whether you searched the web for "how to install sphinx_rtd_theme" or read its documentation.
The error message provides a clue:
Please install it manually. (pip install sphinx_rtd_theme)
Or you could try following the directions in the manual.
On my Mac OS X installation, I encountered this problem, despite following the simple instructions to the letter.
Others have reported having the problems as well, on this Github issue: https://github.com/readthedocs/sphinx_rtd_theme/issues/618
In my case, the problem turned out to be an issue with my python environment (I was using the default system python 2.7 for Mac). I ended up switching to pyenv with python 3.7.3, and that fixed the issue.
Instructions for Mac (from https://opensource.com/article/19/5/python-3-default-mac):
$ brew install pyenv
$ pyenv install 3.7.3
$ pyenv global 3.7.3
$ pyenv version
3.7.3 (set by /Users/mbbroberg/.pyenv/version)
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc
To verify that it worked:
$ which python
/Users/mbbroberg/.pyenv/shims/python
$ python -V
Python 3.7.3
$ pip -V
pip 19.0.3 from /Users/mbbroberg/.pyenv/versions/3.7.3/lib/python3.7/site-packages/pip (python 3.7)
Don't forget to pip install sphinx sphinx_rtd_theme afterward.
In my case (building from RTD theme source), the problem seemed to be caused by a change in behaviour of the html_theme_path config value in conf.py. Whilst paths relative to the makefile directory used to be accepted, paths must now be relative to the configuration directory:
html_theme_path
A list of paths that contain custom themes, either as subdirectories or as zip files. Relative paths are taken as relative to the configuration directory.
New in version 0.6.
— Sphinx documentation > Configuration
I had the same problem on a Windows 10 Pro laptop. I had installed Python 3.9 from the Windows store. I had to first find where Python and pip applications were installed and add that to the PATH variable. This was in a folder that was looked:
c:\users\<username>\appdata\local\programs\python\python39\Scripts
Then I installed sphinx using:
pip install -U sphinx
Then I had to set the SPHINXBUILD env variable to the right value:
SPHINXBUILD="c:\users\<username>\appdata\local\programs\python\python39\Scripts\sphinx-build.exe"
When I tried to use the sphinx_rtd_theme I kept getting the error:
Theme error:
sphinx_rtd_theme is no longer a hard dependency since version 1.4.0. Please install it
manually.(pip install sphinx_rtd_theme)
I ran the following command:
pip install sphinx_rtd_theme
But when I tried to run make html it gave the error:
Running Sphinx v3.5.1
Configuration error:
There is a syntax error in your configuration file: bad input (conf.py, line 57)
Finally I had to make the following changes in my conf.py file:
# Add this to the top of the conf.py file
import os
import sys
sys.path.insert(0, os.path.abspath('C:\\Users\\ <username>\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages'))
import sphinx_rtd_theme
extensions = [
"sphinx_rtd_theme",
]
It looks like sphinx-build is not able to get the location of the sphinx_rtd_theme package unless you give the explicit path in the manner above. “¯_(ツ)_/¯“

`dyld: Library not loaded` error preventing virtualenv from loading

When I tried creating a virtual environment with python using the command virtualenv venv from Terminal, I got the following error:
Using base prefix '/Users/zacharythomas/anaconda3'
New python executable in /Users/zacharythomas/venv/bin/python
dyld: Library not loaded: #rpath/libpython3.6m.dylib
Referenced from: /Users/zacharythomas/venv/bin/python
Reason: image not found
ERROR: The executable /Users/zacharythomas/venv/bin/python is not functioning
ERROR: It thinks sys.prefix is '/Users/zacharythomas' (should be '/Users/zacharythomas/venv')
ERROR: virtualenv is not compatible with this system or executable
I'm not the first person to encounter a similar error -- I tried following this answer's recommendations and running:
gfind ~/.virtualenvs/my-virtual-env/ -type l -xtype l -delete
That didn't help. Nor did running sudo virtualenv venv to run commmand as a super user.
What should I investigate next?
I had the exact same error message. Ray Donnelly at Continuum Analytics Support Group provided the following solution, which resolved the issue for me:
When you pip installed virtualenvwrapper, pip will have installed
virtualenv for you as it is a dependency. Unfortunately, that
virtualenv is not compatible with Anaconda Python. Fortunately, the
Anaconda Distribution has a virtualenv that is compatible. To fix
this:
pip uninstall virtualenv
conda install virtualenv
can't get virtualenv to work with anaconda3 v4.3 on mac

Categories

Resources