Issues Installing Python Modules Under Windows - python

I am trying to setup a Python development environment in Visual Studio 2013 using the new PTVS. However, I need to be able to develop in both Python 2.7 and Python 3.3. Here's what I have done so far for both versions:
Installed distribute
Installed pip
Added C:\Python 3.3\Scripts & C:\Python 2.7\Scripts to my Path environment variable.
So in the Scripts folders I have:
easy_install.exe
easy_install-3.3.exe
pip.exe
pip-3.3.exe
easy_install.exe
easy_install-2.7.exe
pip.exe
pip-2.7.exe
Along with the executables are the corresponding python scripts.
Now having done this, I am trying to install a Python module RPi.GPIO, but I am getting the following error message:
C:\Windows\system32>pip-2.7 install RPi.GPIO==0.5.3a
Downloading/unpacking RPi.GPIO==0.5.3a
Downloading RPi.GPIO-0.5.3a.tar.gz
Running setup.py egg_info for package RPi.GPIO
Installing collected packages: RPi.GPIO
Running setup.py install for RPi.GPIO
building 'RPi.GPIO' extension
error: Unable to find vcvarsall.bat
Complete output from command "C:\Program Files\Python 2.7\python.exe" -c "import set
uptools;__file__='c:\\users\\jon\\appdata\\local\\temp\\pip_build_Jon\\RPi.GPIO\\setup.p
y';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install
--record c:\users\jon\appdata\local\temp\pip-svl0a1-record\install-record.txt --single-
version-externally-managed:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\RPi
copying RPi\__init__.py -> build\lib.win-amd64-2.7\RPi
running build_ext
building 'RPi.GPIO' extension
error: Unable to find vcvarsall.bat
----------------------------------------
Cleaning up...
Command "C:\Program Files\Python 2.7\python.exe" -c "import setuptools;__file__='c:\\use
rs\\jon\\appdata\\local\\temp\\pip_build_Jon\\RPi.GPIO\\setup.py';exec(compile(open(__fi
le__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\jon\ap
pdata\local\temp\pip-svl0a1-record\install-record.txt --single-version-externally-manage
d failed with error code 1 in c:\users\jon\appdata\local\temp\pip_build_Jon\RPi.GPIO
Storing complete log in C:\Users\Jon\pip\pip.log
C:\Windows\system32>
It's trying real hard, but it is failing somewhere, and I can't trace it back to the source. Likewise, I always get the error: Unable to find vcvarsall.bat know matter what module I try to install. What would cause this?
I have tried removed one of the interpreters path from the environment variables, because I thought that the duplicate easy_install.exe instances might be conflicting. Making this change didn't help.
Should the install be nearly as simple as:
pip-2.7 install RPi.GPIO==0.5.3a
or
pip-3.3 install RPi.GPIO==0.5.3a
UPDATE: I just tried install RPi.GPIO by using the command:
pip-3.3 install RPi.GPIO
and it was successfully installed, but the version is way out of date. Hm..?

Related

installing openbabel with pip for linux in venv

I am trying to install openbabel with pip on a linux computer without root access and also using a virtual environment. I run the following command
pip install openbabel --user --log LOG
and then I get the following error:
Collecting openbabel
Using cached openbabel-2.4.1.tar.gz (74 kB)
Building wheels for collected packages: openbabel
Building wheel for openbabel (setup.py) ... error
ERROR: Failed building wheel for openbabel
Running setup.py clean for openbabel
Failed to build openbabel
Installing collected packages: openbabel
Running setup.py install for openbabel ... error
ERROR: Command errored out with exit status 1: /users/name/env_for_pymatgen/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-b51wnefv/openbabel/setup.py'"'"'; __file__='"'"'/tmp/pip-install-b51wnefv/openbabel/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-4207icvx/install-record.txt --single-version-externally-managed --compile --install-headers /users/name/env_for_pymatgen/include/site/python3.6/openbabel Check the logs for full command output.
The main problems seems to be
Error: SWIG failed. Is Open Babel installed?
You may need to manually specify the location of Open Babel include and library directories. For example:
python setup.py build_ext -I/usr/local/include/openbabel-2.0 -L/usr/local/lib
python setup.py install
I see many people had similar issues with setup.py and they are advised to go to the directory and run the same command again, but I don't know what directory I should go to...
EDIT
Would it work if I download openbabel from github and give the path to it?
From my experience, instead of pip install <package_name>, download a wheel file from here which has python binaries built from source code found on PyPI.
After that, open a terminal where you downloaded .whl files and then type :
pip install nameOfYourFile.whl
in my case it's :
pip install openbabel-3.1.1-cp38-cp38-win32.whl
EDIT: be sure to download a version matching your python version otherwise the package will not install.
EDIT2:
I honestly didn't notice that the answer is focused on Linux, so to answer your question, your most reliable option is to build it from source with the python bindings and swig flags enabled, this can be done by following the compiling instructions.
Those instructions still work for the latest version of openbabel in the GitHub repo as of the date of this edit, and i could successfully compile a working openbabel with the python bindings (pybel) on Ubuntu 21.10.

Installing pocketsphinx python module: command 'swig.exe' failed

I'm getting something like this. Can anyone please tell me how to fix this.
C:\Users\krush\Documents\ML using Python>pip install pocketsphinx
Collecting pocketsphinx
Using cached pocketsphinx-0.1.3.zip
Building wheels for collected packages: pocketsphinx
Running setup.py bdist_wheel for pocketsphinx: started
Running setup.py bdist_wheel for pocketsphinx: finished with status 'error'
Complete output from command C:\Users\krush\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\krush\\AppData\\Local\\Temp\\pip-build-cns2i_wb\\pocketsphinx\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\krush\AppData\Local\Temp\tmp3tyvnl9wpip-wheel- --python-tag cp36:
running bdist_wheel
running build_ext
building 'sphinxbase._ad' extension
swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
swig.exe -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/win32 -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
error: command 'swig.exe' failed: No such file or directory
----------------------------------------
Failed building wheel for pocketsphinx
Running setup.py clean for pocketsphinx
Failed to build pocketsphinx
Installing collected packages: pocketsphinx
Running setup.py install for pocketsphinx: started
Running setup.py install for pocketsphinx: finished with status 'error'
Complete output from command C:\Users\krush\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\krush\\AppData\\Local\\Temp\\pip-build-cns2i_wb\\pocketsphinx\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\krush\AppData\Local\Temp\pip-x5mxeczy-record\install-record.txt --single-version-externally-managed --compile:
running install
running build_ext
building 'sphinxbase._ad' extension
swigging swig/sphinxbase/ad.i to swig/sphinxbase/ad_wrap.c
swig.exe -python -modern -Ideps/sphinxbase/include -Ideps/sphinxbase/include/sphinxbase -Ideps/sphinxbase/include/win32 -Ideps/sphinxbase/swig -outdir sphinxbase -o swig/sphinxbase/ad_wrap.c swig/sphinxbase/ad.i
error: command 'swig.exe' failed: No such file or directory
----------------------------------------
Command "C:\Users\krush\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\krush\\AppData\\Local\\Temp\\pip-build-cns2i_wb\\pocketsphinx\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\krush\AppData\Local\Temp\pip-x5mxeczy-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\krush\AppData\Local\Temp\pip-build-cns2i_wb\pocketsphinx\
To fix the problem, I downloaded swig for windows at the time of writing this answer it was 3.0.12
For the latest swig windows version follow this link
Copy swig.exe to the python installation folder (for ex C:/python27)
Open the swigwin-3.0.12/Lib folder and copy all *.swg files to the C:/python27/Lib or equivalent python path
Open swigwin-3.0.12/Lib/python and copy all the files to C:/python27/Lib
Open the swigwin-3.0.12/Lib folder and copy over the typemaps folder to C:/python27/Lib
(Also make sure you have Microsoft Visual C++ Compiler for Python installed)
These steps worked for me.
conda install swig
pip install pocketsphinx
I didn't want to do all that setup other people are suggesting so I tried this and it worked.
This probably only works if you are using Anaconada though.
Instead of copying Swig files to the Python folder, you can simply add Swig`s location to the environment variables:
Press Ctrl+S
Type env and press Enter
Double click on Path
Add the path-to-Swig to the last blank line
Click OK and restart your PC
You try to install pocketsphinx with pip, that will download and compile this module. It requires some compiling tool like swig.
Another solution is to install a binary version of pocketsphinx. You can download a binary version here. You have to select the correct version with respect to your installation.
To determine which one you have to download, you can run the following commands, that will tell you which version you require and whether you run a 32 or 64 bit python interpreter.
"C:\Users\krush\Anaconda3\python.exe" --version
"C:\Users\krush\Anaconda3\python.exe" -c "import struct;print(struct.calcsize('P') * 8)"
Below are some commands that you may enter once you have downloaded the correct version
"C:\Users\krush\Anaconda3\python.exe" -m pip install pocketsphinx‑0.1.3‑cp35‑cp35m‑win32.whl
"C:\Users\krush\Anaconda3\python.exe" -m pip install pocketsphinx‑0.1.3‑cp36‑cp36m‑win_amd64.whl
I was also getting same error, while installing in ubuntu 16.04, I executed following commands:
sudo apt-get install -y python python-dev python-pip build-essential swig git libpulse-dev
sudo pip install pocketsphinx
source: pocketsphinx-python
In case you are working on anaconda navigator.
Just go to environment.
Search swig, your package will be displayed. Select the package and click on apply button.
It will also give a prompt list of other dependencies, which need to be installed with swig.
So just select all and click on apply button.
All the dependencies will be installed in your root directory of anaconda.
This worked for me, hope it helps.
There are few set of commands to resolve this. Just execute them:
sudo apt-get install -y python3 python3-dev python3-pip build-essential swig git libpulse-dev
sudo apt-get install libasound2-dev
sudo pip install pocketsphinx
what works for me is installing swing from conda and
conda install swig
if installed search where it is installed
where swig
then add that path to your environment variable
For mac users getting similar issues, there seems to be a problem with the current pip install framework. I followed this thread and used the solution linked. It doesn't seem like there will be a pip fix anytime soon.
Note you'll have to brew install swig before running the above steps - homebrew install link.
pip install pipwin
python -m pipwin install pocketsphinx
You can also use pipwin to install pocketsphinx.
For a purely pip-based fix (may or not work depending on your exact issue/system):
pip install swig
pip install pocketsphinx
pip freeze > requirements.txt
Fixed the issue simply for me. With pip freeze, you're likely to not have the issue again if cloning the project in another system (since swig will be installed just with pip install -r requirements.txt)
This is the kind of things for which it becomes REALLY worthwhile to look into using virtualenv or similar, instead of polluting (and endlessly re-configuring) your system.
I know I am late, but what worked for me was to download the pre-built wheel file and install it manually (tested on Windows. I am pretty sure it will only work on Windows).
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pocketsphinx
Just grab the right one (cp39 = python 3.9). When it finishes downloading, navigate to your downloads folder in cmd, and issue the following command:
pip install pocketsphinx-0.1.15-cp39-cp39-win_amd64.whl
NOTE: Change pocketsphinx-0.1.15-cp39-cp39-win_amd64.whl to the name of the whl file you downloaded. I grabbed this one because I use Python 3.9 64bit version.

How do I install openbabel for Python 3.6 in Windows 10?

I am using Python for making a script to work with some chemical structures in my PhD. I want to install openbabel libraries for python. I tried my best but I could not install it. It always gives error:
Error: SWIG failed. Is Open Babel installed?
Here is the Python Path on my PC: C:\Users\malih\AppData\Local\Programs\Python\Python36-32. Openbabel is installed at the following path C:\Program Files (x86)\OpenBabel-2.3.1.
When I run python -m pip install openbabel, it gives the following error:
C:\Users\malih>python -m pip install openbabel
Collecting openbabel
Using cached openbabel-2.4.1.tar.gz
Installing collected packages: openbabel
Running setup.py install for openbabel ... error
Complete output from command C:\Users\malih\AppData\Local\Programs\Python\Python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\malih\\AppData\\Local\\Temp\\pip-build-glr82a7x\\openbabel\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\malih\AppData\Local\Temp\pip-02z3p_a9-record\install-record.txt --single-version-externally-managed --compile:
running install
running build_ext
Warning: pkg-config could not be found.
Guessing Open Babel location:
- include_dirs: ['C:\\Users\\malih\\AppData\\Local\\Programs\\Python\\Python36-32\\include', 'C:\\Users\\malih\\AppData\\Local\\Programs\\Python\\Python36-32\\include', '/usr/local/include/openbabel-2.0']
- library_dirs: ['C:\\Users\\malih\\AppData\\Local\\Programs\\Python\\Python36-32\\libs', 'C:\\Users\\malih\\AppData\\Local\\Programs\\Python\\Python36-32\\PCbuild\\win32', '/usr/local/lib']
building '_openbabel' extension
swigging openbabel-python.i to openbabel-python_wrap.cpp
swig.exe -python -c++ -small -O -templatereduce -naturalvar -IC:\Users\malih\AppData\Local\Programs\Python\Python36-32\include -IC:\Users\malih\AppData\Local\Programs\Python\Python36-32\include -I/usr/local/include/openbabel-2.0 -o openbabel-python_wrap.cpp openbabel-python.i
Error: SWIG failed. Is Open Babel installed?
You may need to manually specify the location of Open Babel include and library directories. For example:
python setup.py build_ext -I/usr/local/include/openbabel-2.0 -L/usr/local/lib
python setup.py install
----------------------------------------
Command "C:\Users\malih\AppData\Local\Programs\Python\Python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\malih\\AppData\\Local\\Temp\\pip-build-glr82a7x\\openbabel\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\malih\AppData\Local\Temp\pip-02z3p_a9-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\malih\AppData\Local\Temp\pip-build-glr82a7x\openbabel\
I tried to follow the instructions on this page but they are purely for linux and I could not follow up them for Windows:
How do I use python-openbabel in Travis CI?
I also tried to install pkg-config from the following guide but even after that, it gives the same error:
How to install pkg config in windows?
Please help me on this as my work is based on this and I am stuck at this point. Thanks in advance for your time.
pip install is notoriously non-windows friendly. Either go to openbabel website and download + install windows binary, then download + install python binding, or use the unoffical official openbabel python windows build, then cd into the downloaded directory, and perform pip install OPENBABEL_FILE_WINDOWS.whl
I recently had do some quite a bit of work on 2D mol file -> 3D mol file translation using openbabel. Let me know how it works out for you.
--
edit: I should also add, python3.x is breakingly different to python2.x. So if anything breaks, try it with python2.x
This is somewhat old, but the problems still persist so i'll answer nonetheless.
The precompiled Windows binary (most likely) doesn't come with SWIG built-in, which in turn doesn't offer language bindings and gives you the error when installing from pip.
A workaround to this is to install a wheel from the unofficial Windows binaries website just like pandamakes answered.
However, the wheels already comes bundled with a precompiled obabel, so you really don't need to install the windows binaries version (the one that comes with the setup and all), but you have to know that if you're willing to ship a python script that uses this library, know that it will interfere with systems that do have BABEL_DIR in the environment variables, to fix this you have to include the whole openbabel directory from YourPythonDirectory/lib/site-packages/. in your script's folder.
Another important note is that some babel builds from the unofficial binaries website have a bug where they do not detect all file formats, especially the most common ones like sdf/pdb/mol2 or even smiles. The only versions i have confirmed working somewhat flawlessly so far are the openbabel‑3.1.1‑cp36‑cp36m‑win32.whl and openbabel‑3.1.1‑cp38‑cp38‑win32.whl.

installing a python package from tar.gz

I need to use the cvxopt package for python 3. I run Ubuntu.
So I downloaded cvxopt-1.1.9.tar.gz and extracted the content (a single folder called cvxopt-1.1.9) into a folder
/home/myname/TargetFolder/
manually, not via the command window.
When I run the sequence .configure, then make and then sudo make install, none of them works.
There is a setup.py file in /home/myname/TargetFolder/cvxopt-1.1.9/. When I go to that directory in the command window and type python setup.py install, then I get the following error message:
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/home/myname/anaconda3/lib/python3.5/site-packages/test-easy-install-6110.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/home/myname/anaconda3/lib/python3.5/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
https://pythonhosted.org/setuptools/easy_install.html
That link doesn't exist anymore.
So I follow the advice on http://cvxopt.org/install/ . Apart from the "python setup.py install" command, which didn't work for me, I tried the second thing on their list. Namely "pip install cvxopt"
This gave:
Collecting cvxopt
Downloading cvxopt-1.1.9.tar.gz (1.9MB)
100% |████████████████████████████████| 1.9MB 271kB/s
Building wheels for collected packages: cvxopt
Running setup.py bdist_wheel for cvxopt
Complete output from command /home/myname/anaconda3/bin/python3 -c >"import setuptools;file='/tmp/pip-build-r3o_hfm6/cvxopt/setup.py';>exec(compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" bdist_wheel -d /tmp/tmpv0ura7txpip-wheel-:
running bdist_wheel
running a lot of other stuff
and then
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Failed building wheel for cvxopt
Failed to build cvxopt
and then
Installing collected packages: cvxopt
Running setup.py install for cvxopt
Complete output from command /home/myname/anaconda3/bin/python3 -c "import setuptools, tokenize;file='/tmp/pip-build-r3o_hfm6/cvxopt/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-1f4yz1xm-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
UPDATING build/lib.linux-x86_64-3.5/cvxopt/_version.py
set build/lib.linux-x86_64-3.5/cvxopt/_version.py to '1.1.9'
running build_ext
building 'base' extension
and then after some more lines it says:
/usr/bin/ld: cannot find -llapack
/usr/bin/ld: cannot find -lblas
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
Command "/home/myname/anaconda3/bin/python3 -c "import setuptools, tokenize;file='/tmp/pip-build-r3o_hfm6/cvxopt/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-1f4yz1xm-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-r3o_hfm6/cvxopt
You are using pip version 7.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
If I understood more about Linux and Python I could have focused on the important things and shortened the post a little. But since I know nothing, I post everything I did to maximize the possibility of helpful responses.
Maybe I just don't understand how python works. When I include a package I do this with the
import package
command. But import cvxopt doesn't work. So if I understood what it is exactly doing, then maybe I could use logic to give her or him that cvxopt package, where it is looking for it.
Since you are running Ubuntu, simply run sudo apt-get install python-cvxopt
I can install it this way on 16.04. Not sure what version you are running.
It does look like the compiler (gcc) is complaining because you are missing dependencies (blas). Installing via the package manager should solve your issues.

Python script not executing (No module named APNSWrapper)

In the terminal I run this command:
Python pnot.py
I get the following error:
Traceback (most recent call last):
File "pnot.py", line 1, in <module>
from APNSWrapper import *
ImportError: No module named APNSWrapper
I have tried to install the module:
pip install APNSWrapper==0.6.1
Requirement already satisfied (use --upgrade to upgrade): APNSWrapper==0.6.1 in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages
Requirement already satisfied (use --upgrade to upgrade): docutils>=0.3 in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages (from APNSWrapper==0.6.1)
Cleaning up...
I have tried to install APNS:
Pip install apns
I get the following error:
Downloading/unpacking apns
Downloading apns-1.1.2.tar.gz
Running setup.py egg_info for package apns
Installing collected packages: apns
Running setup.py install for apns
error: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/__pycache__/apns.cpython-33.pyc: Permission denied
Complete output from command /Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 -c "import setuptools;__file__='/private/var/folders/8g/6w73vzqs04b6f1cq8m8pyswc0000gn/T/pip_build_samiesyed/apns/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/8g/6w73vzqs04b6f1cq8m8pyswc0000gn/T/pip-3yfn_n-record/install-record.txt --single-version-externally-managed:
running install
running build
running build_py
creating build
creating build/lib
copying apns.py -> build/lib
running install_lib
copying build/lib/apns.py -> /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages
byte-compiling /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/apns.py to apns.cpython-33.pyc
error: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/__pycache__/apns.cpython-33.pyc: Permission denied
----------------------------------------
Cleaning up...
Command /Library/Frameworks/Python.framework/Versions/3.3/bin/python3.3 -c "import setuptools;__file__='/private/var/folders/8g/6w73vzqs04b6f1cq8m8pyswc0000gn/T/pip_build_samiesyed/apns/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/8g/6w73vzqs04b6f1cq8m8pyswc0000gn/T/pip-3yfn_n-record/install-record.txt --single-version-externally-managed failed with error code 1 in /private/var/folders/8g/6w73vzqs04b6f1cq8m8pyswc0000gn/T/pip_build_s/apns
Storing complete log in /Users/s/.pip/pip.log
script code:
from APNSWrapper import *
wrapper = APNSNotificationWrapper('cert.pem', True)
for token in ['xxxxxxx']:
token = binascii.unhexlify(token)
apn = APNSNotification()
apn.token(token)
alert = APNSAlert()
alert.body('hello world')
apn.alert(alert)
apn.sound()
wrapper.append(apn)
wrapper.notify()
This is really frustrating me, not sure why the script is not executing.
Most likely pip and python point to different Python installations. One might be from package manager, one might be from the system defaults.
You can find this out by doing commands
which python
which pip
Probably pip installs packages against some other python installation you are trying to use.
The solution to the problem, no matter how it has manifested itself, is to use virtualenv environments for your Python package installations. virtualenv creates a self-contained folder containing the python interpreter and package installations, which you can wipe clean and rebuild in the case of problems.
First install virtualenv.
Then do:
virtualenv venv # Create virtualenv installation in folder called venv
source venv/bin/activate # Modify your shell and PATH to use python from venv/bin/python
pip install apns # Installs apns in venv/lib
python pnot.py # Now it runs your script using venv/bin/python interpreter
# and packages installed in venv/lib/python2.7
More information about python and virtualenv installations
http://opensourcehacker.com/2012/09/16/recommended-way-for-sudo-free-installation-of-python-software-with-virtualenv/

Categories

Resources