pycurl module not available after installation on Snow Leopard - python

I'm running Python 2.6.4 on Mac Snow Leopard. I installed pycurl using:
sudo env ARCHFLAGS="-arch x86_64" easy_install setuptools pycurl==7.16.2.1
The installation completes with no issues and says pycurl is installed in subsequent installation attempts. However, when I try to "import pycurl" in a script, I get a message that pycurl isn't found. I'm not sure what else to do to fix this.

I would suspect you have 2 versions of python on your system. How about removing easy install and reinstalling it.
Remove the current easy install script by typing which easy_install and then rm [easy install full path].
To install easy install
wget http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
Then, try your command again:
sudo env ARCHFLAGS="-arch x86_64" easy_install setuptools pycurl==7.16.2.1

I guess you have 2 different versions of python, you can find out by running command which python

If you have installed Python 2.6.4 using the python.org OS X installer, you need to install the optional 10.4u SDK from the 10.6 Xcode mpkg to install any python packages that include C extension modules.

Related

“Failed building wheel for psycopg2-binary” - Mac OS Catalina using virtualenv

I'm trying to install psycopg2-binary on Mac OS Catalina and Python 3.8. The build fails always when try to install using pip3. Is there any solution for this in Catalina ?
"ERROR: Failed building wheel for psycopg2-binary"
I was able to compile psycopg2 on OS X 10.15.1 Catalina with $VENV/bin/pip install psycopg2 after doing a couple of things, first:
Re-installed xcode command line headers (though it may have just been that I accepted the new terms of service) using xcode-select --install
Linked homebrew ssl headers using export LDFLAGS="-L/usr/local/opt/openssl#1.1/lib" and export CPPFLAGS="-I/usr/local/opt/openssl#1.1/include"
installing with $VENV/bin/pip install psycopg2 where VENV is the directory of my virtual environment
It looks like some others have had successes with just the xcode, but I also needed to add ssl things to the path.
Try ussing the binary version:
pip install psycopg2-binary
If you still have the same issue try using Pipenv instead
and if you still cant install it in pipenv try it with the run command and the binary version:
pipenv run pip install psycopg2-binary

How to fix "module 'platform' has no attribute 'linux_distribution'" when installing new packages with Python3.8?

I had Python versions of 2.7 and 3.5. I wanted the install a newer version of Python which is python 3.8. I am using Ubuntu 16.04 and I can not just uninstall Python 3.5 due to the dependencies. So in order to run my scripts, I use python3.8 app.py. No problem so far. But when I want to install new packages via pip:
python3.8 -m pip install pylint
It throws an error:
AttributeError: module 'platform' has no attribute 'linux_distribution'
So far, I tried:
sudo update-alternatives --config python3
and chose python3.8 and run command by starting with python3 but no luck.
Then:
sudo ln -sf /usr/bin/python3.5 /usr/bin/python3
I also tried running the command by starting with python3 but it did not work either.
How can I fix it so that I can install new packages to my new version of Python?
It looks like at least on my Ubuntu 16.04, pip is shared for all Python versions in /usr/lib/python3/dist-packages/pip.
This is what I did to get it working again:
sudo apt remove python3-pip
sudo python3.8 -m easy_install pip
You might want to install the python 3.5 version of pip again with sudo python3.5 -m easy_install pip.
Python 3.8 removed some stuff. I solved my problems with pip (specifically pip install) by installing pip with curl.
What worked for me was downloading get-pip.py and run it with Python 3.8:
cd ~/Downloads
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.8 get-pip.py
Source: https://pip.pypa.io/en/stable/installing/
The problem is that package.linux_distribution was deprecated starting with Python 3.5(?). and removed altogether for Python 3.8.
Use the distro package instead. This package only works on Linux however.
I ran into this problem after installing OpenCobolIDE on Linux Mint 20, having upgraded Python to the latest level. have submitted a code fix to the OpenCobolIDE author to review and test. I was able to get the IDE to start up and run with this fix.
Essentially the fix uses the distro package if available, otherwise it uses the old platform package. For example:
This code imports distro if available:
import platform
using_distro = False
try:
import distro
using_distro = True
except ImportError:
pass
Then you can test the value of using_distro to determine whether to get the linux distro type from package or distro, for example:
if using_distro:
linux_distro = distro.like()
else:
linux_distro = platform.linux_distribution()[0]
In my case, removing python-pip-whl package helped:
apt-get remove python-pip-whl
It removed also pip and virtualenv, so I had to install them again:
curl https://bootstrap.pypa.io/get-pip.py | python3
pip install virtualenv
Check if your wheels installation is old. I was getting this same error and fixed it with
python3.8 -m pip install --upgrade pip setuptools wheel
Pylint seems to work on python3.8
I recently had this error and it turns out that I had a package called platform at a folder on my path ahead of the standard library and so the interpreter imported that instead. Check your path to what it is that you're actually importing.
If you have this issue when running a docker-compose up command. The solutions above do not work. You should install docker ce (https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-20-04)

installing pycurl on osx 10.10 - don't know what to do with pycurl-7.10.5

I'm trying to install pycurl.
I downloaded and decompressed pycurl-7.10.5.tar.gz but I don't know what to do with the output.
Could someone help me with the install. I have python 3.5 and 3.3 installed as well as the Eclipse IDE with the PyDev extension.
I'd rather stay away from unix-like command line commands if possible and install from the native OSX interface. Something always goes wrong whenever I try things in the terminal.
For example, the first line of the INSTALL file tells me to
tar -zxvf pycurl-$VER.tar.gz
the response I get is:
tar: Error opening archive: Failed to open 'pycurl-.tar.gz'
Thank you,
Joe
The only real answer is to use a command line, one that you can run the python that you need to install curl to, i.e.:
pip install ./pycurl-7.10.5.tar.gz
if this fails try:
sudo pip install ./pycurl-7.10.5.tar.gz
in the directory that you downloaded the tar.gz to. BTW the terminal is the native interface. You will need to do this twice - once for each python.
You could always write a small python script to take the name of a package and do:
subprocess.call(['pip', 'install', name_of_package])
again you may need to run this with elevated privileges. (I don't have a Mac to try it out on). The good news is that if you are connected to the net at the time then just pip install pycurl should download the latest compatible version and install it all in one operation.
Missing pip?
If pip is missing then you can follow the installing pip instructions which consist of:
To install pip, securely download get-pip.py.
Then run the following (which may require administrator access):
python get-pip.py
If setuptools is not already installed, get-pip.py will install setuptools for you.
To upgrade an existing setuptools, run pip install -U setuptools.
Install behind a proxy:
python get-pip.py --proxy="[user:password#]proxy.server:port"
Upgrade pip
On Linux or OS X:
pip install -U pip
On Windows [5]:
python -m pip install -U pip
On OSX, you need to set the arch flag in the env. Try this, it should build:
sudo env ARCHFLAGS="-arch x86_64" pip3.5 install ./pycurl-7.43.0.tar.gz

Zope installed to wrong version (easy_install and pip)

I downloaded the python egg for zope.interface version 4.0.5 and tried to install it with easy_install and then pip. Both installed it to python 2.7, which is the default on my computer. Is there any way to install it to python3?
I'm on Mac OSX 10.8.3. I've looked around for some solution, but the only one I found with this problem was here: easy_install with various versions of python installed, mac osx, but the answer doesn't work.
I would suggest installing the Homebrew package manager, and installing python 3 with it.
Installing Homebrew:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Installing Python 3
brew install python3
Pip for Python 3 would be installed as pip3 by the above command.
easy_install is depretiated with homebrew, and you don't need to use sudo with pip3 or gem
Note, easy_install is deprecated. We install pip (or pip3 for python3) along with python/python3.
source

Installing python modules for specific version on linux (pySide)

So, to keep it simple. Ubuntu 12.10 has python 3.2 pre installed and it is linked to "python3". I downloaded python 3.3 and it's command is "python3.3". However, I downloaded pySide for python3 from synaptic. Using "from PySide.QtCore import *" fails on python3.3. BUT, when I ran just "python3" (aka 3.2) everything works fine. Synaptic just installed lib for python3.2 which is default for python3 in ubuntu. How can I force synaptic to install modules for python3.3?
Thanks
Try working in a virtual environment with virtualenv. This will keep your python versions/packages separate from each other in case something goes wrong. Use pip to install PySide.
EDIT:
A possible solution is:
~$ sudo easy_install pip
To install virtualenv,
~$ sudo pip install virtualenv
The page for PySide on PyPi has a guide for different platforms on how to install pyqt with virtualenv. Best of luck.
I think you should install the pyside from its source files that have setup.py and then run the command python3.3 setup.py build and sudo python3.3 setup.py install because if you install by apt for example, it will use the default interpreter which is 3.2 that you mentioned.

Categories