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/
Related
I am trying to host a Django app on Heroku. The app works fine on my computer as long as I don't use django-heroku (because I can't install it), and it works fine on Heroku as long as it does have django-heroku. This is not a pressing issue, but it is sort of annoying to have to remove django-heroku to make edits on my computer, and then have to re-insert it before pushing to heroku.
The ideal solution would be to get django-heroku installed on my computer.
Specifications:
Mac running macOS
Conda environment, python 3.7 and 3.8
Here is what I have found so far:
pip 20.0.2 from /Users/lucas/opt/anaconda3/lib/python3.7/site-packages/pip (python 3.7):
Cannot install django-heroku (See error below)
pip 20.1.1 from /Users/lucas/Library/Python/3.7/lib/python/site-packages/pip (python 3.7):
Can install django-heroku, however:
Gives me this warning: (still installs without any problems)
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
running the script with all pythons in the environment say no module called django_heroku
The first version of pip I specified that couldn't install django-heroku gives this error:
pip install django-heroku
Collecting django-heroku
Using cached django_heroku-0.3.1-py2.py3-none-any.whl (6.2 kB)
Collecting psycopg2
Using cached psycopg2-2.8.5.tar.gz (380 kB)
ERROR: Command errored out with exit status 1:
command: /Users/lucas/opt/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/setup.py'"'"'; __file__='"'"'/private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info
cwd: /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/
Complete output (23 lines):
running egg_info
creating /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info
writing /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to /private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file '/private/var/folders/r1/c30g6kr946l2czzpkr2mvrd80000gn/T/pip-install-q1m4s1hh/psycopg2/pip-egg-info/psycopg2.egg-info/SOURCES.txt'
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
If you prefer to avoid building psycopg2 from source, please install the PyPI
'psycopg2-binary' package instead.
For further information please check the 'doc/src/install.rst' file (also at
<https://www.psycopg.org/docs/install.html>).
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I'm not an expert on how things like this work, so I included as much information as I could. I appreciate any help you can give on this.
First, django-heroku is no longer maintained, so my advice is to not use it.
Your problem, though is with psycopg2, as the error mentions, not django-heroku directly. Since django-heroku depends on psycopg2, installing psycopg2-binary probably won't help - and there can be issues with this as well, it's not suitable for serving your site from, although you're probably not doing that on OS X.
To get it working, you need to install the PostgreSQL libraries:
brew install postgresql
Depending on a few things, you may also have problems after that. If you see any errors about gcc and ssl, you can try running:
setenv LDFLAGS "-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib"
For fish, or if you running bash:
export LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib"
It can be tricky, so that may not be enough.
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.
This question already has answers here:
Error installing Turicreate on ubuntu python 3.8.2 on pip
(2 answers)
Closed 2 years ago.
Hello Last few days i am trying to run one script for creating the Modal for machine learning. but I am not able to install the Turicreate package in Pycharm editor.
I follow these steps to run the script.
Download Python 3.7 in this link:
(https://www.python.org/downloads/)
Download the Pycharm Editor(https://www.jetbrains.com/pycharm/)
After that, I set the project interpreter in latest python3.7 and trying to install turicreate but always I got error.
Collecting turicreate
Using cached https://files.pythonhosted.org/packages/db/54/167837569bcb816b3fe68f003f18d07ab9d5ac31b2b12b8f9b07b1ccc7a4/turicreate-4.2.tar.gz
Building wheels for collected packages: turicreate
Running setup.py bdist_wheel for turicreate: started
Running setup.py bdist_wheel for turicreate: finished with status 'error'
Complete output from command /Users/tikam/MLTikam1/venv/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/rh/qx_0gvzn6kzbqjvvbbh66t080000gn/T/pycharm-packaging1/turicreate/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 /private/var/folders/rh/qx_0gvzn6kzbqjvvbbh66t080000gn/T/pip-wheel-qez5g2v_ --python-tag cp37:
running bdist_wheel
running build
installing to build/bdist.macosx-10.9-x86_64/wheel
running install
==================================================================================
ERROR
If you see this message, pip install did not find an available binary package
for your system. Supported platforms are:
* Linux x86_64 (including WSL on Windows 10).
* macOS 10.12+ x86_64.
* Python 2.7, 3.5, or 3.6.
Other possible causes of this error are:
* Outdated pip version (try `pip install -U pip`).
==================================================================================
Running setup.py clean for turicreate
Failed to build turicreate
Installing collected packages: turicreate
Running setup.py install for turicreate: started
Running setup.py install for turicreate: finished with status 'error'
Complete output from command /Users/tikam/MLTikam1/venv/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/rh/qx_0gvzn6kzbqjvvbbh66t080000gn/T/pycharm-packaging1/turicreate/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /private/var/folders/rh/qx_0gvzn6kzbqjvvbbh66t080000gn/T/pip-record-kjt0p8as/install-record.txt --single-version-externally-managed --compile --install-headers /Users/tikam/MLTikam1/venv/include/site/python3.7/turicreate:
running install
==================================================================================
ERROR
If you see this message, pip install did not find an available binary package
for your system. Supported platforms are:
* Linux x86_64 (including WSL on Windows 10).
* macOS 10.12+ x86_64.
* Python 2.7, 3.5, or 3.6.
Other possible causes of this error are:
* Outdated pip version (try `pip install -U pip`).
==================================================================================
----------------------------------------
Failed building wheel for turicreate
Command "/Users/tikam/MLTikam1/venv/bin/python -u -c "import setuptools, tokenize;file='/private/var/folders/rh/qx_0gvzn6kzbqjvvbbh66t080000gn/T/pycharm-packaging1/turicreate/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /private/var/folders/rh/qx_0gvzn6kzbqjvvbbh66t080000gn/T/pip-record-kjt0p8as/install-record.txt --single-version-externally-managed --compile --install-headers /Users/tikam/MLTikam1/venv/include/site/python3.7/turicreate" failed with error code 1 in /private/var/folders/rh/qx_0gvzn6kzbqjvvbbh66t080000gn/T/pycharm-packaging1/turicreate/
Please suggest what step i need to follow to install the turicreat package.
I want to run this script:
Script **************
import turicreate as tc
data = tc.SFrame('photoLabel.sframe')
model = tc.image_classifier.create(data, target='photoLabel')
predictions = model.predict(data)
model.export_coreml('MyClassifier.mlmodel')
It is not supported Python 3.7 right now. So you have to return to the previous Python version.
brew unlink python
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
Source:https://github.com/apple/turicreate/issues/788
Or you can create virtual env to run turicreate on
Download the Python3.6 tgz file from the official website (eg. Python-3.6.6.tgz)
Unpack it with tar -xvzf Python-3.6.6.tgz
cd Python-3.6.6
run ./configure
run make altinstall to install it
(install vs altinstall explanation here Difference in details between "make install" and "make altinstall")
You'll normally find your new python install under /usr/local/bin. Now you can create a new virtualenv specifying the python version with:
virtualenv --python=python3.6 env3.6
Get into the virtualenv running the command source env3.6/source/bin/activate.
Install turicreate with the classic pip install turicreate
source:https://github.com/tensorflow/tensorflow/issues/17022
I tried to run pip install flask on Arch Linux and I get the following error:
Collecting itsdangerous>=0.24 (from flask)
Using cached https://files.pythonhosted.org/packages/dc/b4/a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4/itsdangerous-0.24.tar.gz
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10->flask)
Using cached https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
Installing collected packages: Werkzeug, click, MarkupSafe, Jinja2, itsdangerous, flask
Running setup.py install for MarkupSafe ... done
Running setup.py install for itsdangerous ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9u23zlnf/itsdangerous/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-r51zrnnv-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib
copying itsdangerous.py -> build/lib
running install_lib
copying build/lib/itsdangerous.py -> /usr/lib/python3.6/site-packages
byte-compiling /usr/lib/python3.6/site-packages/itsdangerous.py to itsdangerous.cpython-36.pyc
error: [Errno 13] Permission denied: '/usr/lib/python3.6/site-packages/__pycache__/itsdangerous.cpython-36.pyc.140591598548528'
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9u23zlnf/itsdangerous/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-r51zrnnv-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9u23zlnf/itsdangerous/
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.`
What does this error mean?
Use
pip install --user flask
instead.
You are getting a Permission Denied error which means that you don't have access to write to a specific location.
When you are using pip install flask, pip will try to install the package flask somewhere in /usr/lib/python3.6/../. This directory requires root access something you don't have at the time you were running pip install flask.
By using the --user flag, you are telling pip to install the package to your home directory which does not require root permissions.
It's always a good practice to install Python packages using the --user flag because you are not installing that package system-wide. When you use sudo pip install package_name then you are installing/upgrading a package (with dependencies) system-wide. Python in some systems power-up critical system components, forcing the system to install a new version of a package might break some critical system component. Usually, systems are stuck to a specific package version just to support backwards-compatibility, you might break this if you try to install it as a sudo.
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
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..?