Unable to instal django-heroku on mac - python

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.

Related

How to install psycopg2 on Python 3.9 on Windows?

I have been trying to install psycopg2 (pip install psycopg2), but I keep getting this error.
I have also tried with: pip install psycopg2-binary but I'm getting the same error.
Here is the error message:
ERROR: Command errored out with exit status 1:
command: 'c:\users\viktor\pycharmprojects\wemport\venv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Viktor\\AppData\\Local\\Temp\\pip-install-015ceiei\\psycop
g2\\setup.py'"'"'; __file__='"'"'C:\\Users\\Viktor\\AppData\\Local\\Temp\\pip-install-015ceiei\\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 'C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl'
cwd: C:\Users\Viktor\AppData\Local\Temp\pip-install-015ceiei\psycopg2\
Complete output (23 lines):
running egg_info
creating C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info
writing C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\PKG-INFO
writing dependency_links to C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\dependency_links.txt
writing top-level names to C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\psycopg2.egg-info\top_level.txt
writing manifest file 'C:\Users\Viktor\AppData\Local\Temp\pip-pip-egg-info-3shb13sl\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.
How to fix that?
The following will install prebuilt binaries for windows. It's worked for me on 3.9. You can uninstall pipwin after install psycopg2.
pip install pipwin
pipwin install psycopg2
Optional after psycopg2 installed:
pip uninstall pipwin
if u use linux
You need to make sure that you install wheel model
and Try that
sudo ./venv/bin/python -m pip install wheel
after that install psycopg2 and psycopg2-binary
sudo ./venv/bin/python -m pip install psycopg2
sudo ./venv/bin/python -m pip install psycopg-binary

problem with installing Pygame on Anaconda

I want to install pygame on python. I have ubuntu 20.04 (which has python3.8 already installed) and Anaconda.
pip is connected to Anaconda: which pip shows it's at /home/mohammad/anaconda3/bin/pip.
I use pip to install pygame on Anaconda. But pip install pygame shows error. How can I install pygame on Anaconda?
I can simply install pygame by deactivating Anaconda Enviroment and using pip which installs it on system python (It shouldn't have any problem). But I want to have pygame on Anaconda.
I don't really know where the problem is.
$ pip install pygame
Collecting pygame
Using cached pygame-1.9.6.tar.gz (3.2 MB)
ERROR: Command errored out with exit status 1:
command: /home/mohammad/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-z7x7jtmx/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-z7x7jtmx/pygame/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 /tmp/pip-pip-egg-info-ctnap_n6
cwd: /tmp/pip-install-z7x7jtmx/pygame/
Complete output (25 lines):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
/bin/sh: 1: sdl-config: not found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Hunting dependencies...
WARNING: "sdl-config" failed!
WARNING: "pkg-config freetype2" failed!
Unable to run "sdl-config". Please make sure a development version of SDL is installed.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
python3 -m pip install pygame==2.0.0.dev6
Please try running the above mentioned code on your platform.
There isn't a build of 2.0.0.dev3 for Python 3.8. Python 3.8 wasn't out when dev3 was released. You want the latest, so change your command to that .
However , if that also doesn't help you as well , try sudo apt install python3-pygame

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.

Python package cx_Oracle==5.1.3 Microsoft Visual C++ 9.0 is required for

Trying to install cx_Oracle==5.1.3 package onto windows 2012 server Through Jenkins. Using python 2.7 with setuptools-41.1.0.dist-info. I have installed Microsoft C++ Compiler for Python 9.0 but pip complains it can't find it
Run the pip install code from the command line and it works. Tried setting various paths, tried calling the C++ environment from Jenkins. Scoured the internet for advice, not getting anywhere :(
call "C:\Users*****\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat" x86_amd64
%WORKON_HOME%\emileTest\Scripts\pip install cx_Oracle==5.1.3
This is the Jenkins error log
Collecting cx_Oracle==5.1.3
Using cached https://files.pythonhosted.org/packages/be/25/afc07a79ed268f6ab2e8959cfcff997504ce09500b881a1d93f92904762e/cx_Oracle-5.1.3.tar.gz
Building wheels for collected packages: cx-Oracle
Building wheel for cx-Oracle (setup.py): started
Building wheel for cx-Oracle (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: 'c:\envs\emiletest\scripts\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\windows\temp\pip-install-umf517\cx-Oracle\setup.py'"'"'; file='"'"'c:\windows\temp\pip-install-umf517\cx-Oracle\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:\windows\temp\pip-wheel-kg80iv' --python-tag cp27
cwd: c:\windows\temp\pip-install-umf517\cx-Oracle\
Complete output (5 lines):
running bdist_wheel
running build
running build_ext
building 'cx_Oracle' extension
error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
To avoid this build problem with Jenkins, what I did is install the old cx_Oracle version under the default python site packages. I use virtualenv so I can create a virtual environment and basically tell it to inherit the default python site packages like this:
mkvirtualenv --system-site-packages env_name
So this environment will have access to the default cx_Oracle package. Since the requirement will already be satisfied, pip will not try to install it again when building in Jenkins.
I would love to upgrade a lot of things but it's just not seen as priority as long as everything works.

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.

Categories

Resources