Python troubles

rsashna
2 min readJul 14, 2020

when the snake loses its slink

Included troubles for mac:
_tkinter module not found, tcl-tk there but not, python3 updating, old xcode. The order of installation causes too many dead ends.
Could not import the lzma module…

Photo by Marius Masalar on Unsplash

Xcode issues — first if xcode is not installed properly or commandline tools not installed properly or the downloaded version has an ‘unknown error’
-download from appstore
-if ‘unknown error’ occurs, change date to some early date in Oct 2019 then download (should work)
-change back date

Python3 needs updating and everything else— check the python version needed for project first
then forget updating python3 and uninstall it instead.

Remove python3 and pyenv

pyenv uninstall 3.7.0
or whatever old version

brew uninstall pyenv && rm -rf ~/.pyenv

Install Tcl/tk and zlib

brew install zlib
brew install tcl-tk

Add paths to ./bash_profile

# For compilers to find zlib you may need to set:
export LDFLAGS=”${LDFLAGS} -L/usr/local/opt/zlib/lib”
export CPPFLAGS=”${CPPFLAGS} -I/usr/local/opt/zlib/include”

# For pkg-config to find zlib you may need to set:
export PKG_CONFIG_PATH=”${PKG_CONFIG_PATH} /usr/local/opt/zlib/lib/pkgconfig”

Then get the python download with pyenv

pyenv install 3.8.3

and then check where the python3 version was downloaded with

which python

copy that location, mine was through shims, and add to ./bash_profile

alias python=’location’

running python should now go to version specified, >>>import tkinter should not throw complaints, (if that fails try >>>import Tkinter --this working means you're on version 2 still)

stackoverflows that got me there:

Error Messages warning LZMA Missing from Python:

Got the following message when installing pandas complaining about lzma compression

‘Users/uName/.pyenv/versions/3.7.4/lib/python3.7/site-packages/pandas/compat/__init__.py:97:UserWarning: Could not import the lzma module. Your installed Python is incomplete. Attempting to use lzma compression will result in a RuntimeError.
warnings.warn(msg)’

To fix, python needs to be installed after installing xz. The order of installs matter here too.
Correct version depends on the error message.

pip freeze > latestPackages.txt

pyenv uninstall 3.x.x

brew install xz

pyenv install 3.x.x

pip install pandas
Run the program causing the issue, it should be fixed. Check for missing pip installations (pip list, pip3 list)

pip install [missing stuff]
If anything is missing

--

--