Can't Install setuptools from within PyCharm on Linux

Completed
Hi there,

Linux Mint Petra x64 and PyCharm CE v3.1.2 build 133.1229.

I have installed Python 2.7, 3.3 and 3.4 to /opt/Pythonx.x with the intention to use these installations for development.  I chose to do it this way so I don't have to mess around with the system.  Bitter experience...

I can add these installations fine as interpreters, but I am unable to install setuptools from within PyCharm.

Here's the log file:

Install package failed.

The following command was executed:

packaging_tool.py untar /home/tim/Python/pycharm-community-3.1.2/helpers/setuptools-1.1.5

The error output of the command:

Traceback (most recent call last):
  File "/home/tim/Python/pycharm-community-3.1.2/helpers/packaging_tool.py", line 136, in main
    retcode = untarDirectory(name)
  File "/home/tim/Python/pycharm-community-3.1.2/helpers/packaging_tool.py", line 86, in untarDirectory
    tar = tarfile.open(filename)
  File "/opt/python3.4/lib/python3.4/tarfile.py", line 1554, in open
    raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully


This happens for all my the installations in /opt/Pythonx.x.  I have confirmed that the tar file is actually present.

Linux is new to me, and I have to say this was significantly easier to do in Windows.  But I did lose my hard disk and don't have the installation key anymore, so here I am...

If anyone could help out I'd be eternally grateful!

Regards,

Tim
5 comments
I found a solution myself!  Proud moment for me and I shall post my solution in case someone else has the same issue.

I had to download zlib from http://zlib.net and compile it first.  The headers were installed to /usr/local/include.

Then I had to compile Python from source, i.e.

./configure -with-zlib=/usr/local/include –prefix=/opt/python3.4
make
sudo make install


After that I installed setuptools and pip manually.  Hope it helps someone.
0
I had this same problem and your instructions were the perfect fix, thanks.
0

Oh wow, thank you so much! I got stuck with this in 2018, recompiling Python with zlib did the trick, nothing else did. How did you come up with this?

0

Just found this thread while troubleshooting in Nov 2018 an error using mercurial (hg) status, telling me there is no zlib module for Python (Mac OS Mojave, Python installed via brew) 

Looks like zlib may need to be compiled from source on Mojave (see this Stack Overflow brew/zlib question)

0

Just found this thread while troubleshooting in Nov 2018 an error using mercurial (hg) status, telling me there is no zlib module for Python (Mac OS Mojave, Python installed via brew) 

Looks like zlib may need to be compiled from source on Mojave (see this Stack Overflow brew/zlib question). 

Update: Found many threads suggesting using the XCode package tool to install the command line libraries under /usr/local

"sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /"

Problem: that installer pkg does not exist on my system (some say it went away as of 10.14.1). 

I tried this trick from a Stack Overflow setup to make the lib dir available for brew... 

# 2018-11-05 Trying to enable brew to install with zlib python correctly
# using XCode /usr/local/lib
# See https://stackoverflow.com/questions/51274905/brew-install-on-mojave
export CFLAGS="-I/usr/local/include -L/usr/local/lib -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include"

Then I ran : brew reinstall python

No worky!

Finally, tried a reinstall of python 2! 

brew reinstall python@2

Now, command line hg works! Yay! 

Hope this helps somebody else. ;-)

0

Please sign in to leave a comment.