Trouble installing psycopg2 on a virtualenv using python3 - python-3.x

The other day I asked a question about why I couldn't install psycopg2 on my mac. The problem, I realized, lies with python3.
I am working with flask and have been running in a virutalenv that uses python3. When attempting to install psycopg2 (using pip install psycopg2), it fails miserably. I attempted the same thing on the ubuntu virtual machine on my computer, with the same problem. However, when I attempt to install psycopg2 on a virtualenv using the python version installed on my computer (2.7.2), it works fine. It also works on the Ubuntu side.
Hence, the problem is with using python3 in the virtualenv. My friend and mentor helped me develop a workaround on my Ubuntu side. Essentially what we did was download python3, then modify the .bashrc to use the new python3 when typing python3 from terminal. Then, when we setup a new virtualenv using the downloaded python3, and attempted to download psycopg2, there wasn't the problem at all!
Now, so I want to use python3 with projects I am working on, and because I am deploying through Heroku, I need to use psycopg2 to link up my databases. Can anyone help me figure out a workaround on my mac side? Thanks!
P.S. -> Here's the link to my original question:
Can't install pscyopg2 on mac OS X 10.8.4
(Not sure what happened to the comments and original answer from the other stackoverflow user)

I solved this exact problem by installing python3-dev first.

Related

Is Kivy installation possible today without building your own wheel?

This link
shows that in order to install Kivy with python3.11, you must build your own "wheel". Unfortunately for me, the above install fails at the "make install" command. "which python" seems to confirm that i am in the correct virtual environment, but i am not certain.
So we know for sure that if, as of today, you have the most recent version of python, which is python3.11, then you must build your own wheel for Kivy.
That stackoverflow link doesnt work for me, so I thought, well I will just install python3.7 or python3.8. Unfortunately www.python.org does not have installers for versions lower than 3.9. www.python.org does have python3.7 and python3.8 available but those versions do not have "macOS 64-bit...installer" available for them. i am reluctant to try a python install manually without the installer.
my reading of the Kivy documentation confirms that Kivy is happy with python3.7 or python3.8.
So for me, because I want to use a python version that has an installer on www.python.org, I cannot install Kivy without building my own wheel. And that installation fails for me.
Any advice?
The answer is YES, Kivy installation is possible today without building your own wheel. Use python3.10 as of today, February 8, 2023. Kivy wheels are already built for phthon3.10. I installed Python3.10 from www.python.org on my mac laptop running Monterey 12.6. Then I followed the Kivy install instructions at www.kivy.org. The instructions worked perfectly and now I can run Kivy apps from the command line. Next step is to synchronize my python IDE with the environment variables that were used to install Python3.10 and Kivy.

PyMesh Installation on Python 3.6 Windows

I am trying to install Pymesh on Python 3.6.
In my first try, I installed through pip, however it installed a wrong PyMesh than I wanted.
It installed the following, https://pypi.org/project/pymesh/, while I wanted https://pymesh.readthedocs.io/en/latest/
I uninstalled it, and tried installing the later PyMesh, however no luck. There were no instructions for windows. I downloaded the source from github. I extracted and pasted it in C:\Python36\Lib\site-packages
Then I ran python3 setup.py build - when an error showed up, I also tried python3 setup.py install, which worked. However, I am unable to do a simple basic command mentioned in the web page: https://pymesh.readthedocs.io/en/latest/basic.html
It is saying pymesh does not have module name load_mesh.
Looking for the process or thoughts on how to properly install pyMesh for Windows.
My go to solution for problems like this on Windows is always to try it in a conda env first. If that fails, use Docker.

import ortools in mac

I am trying to run some code using ortools on a python environment. I did not have troubles on a windows machine but I am having problems on mac (10.12.6). if in my virtual environment I run
pip freeze
or
conda list
ortools appears in my list of installed packages. But if I try to use it
ipython
from ortools.linear_solver import pywrapplp
I get an error saying that there's no module named ortools. If I go to
mac/anaconda3/envs/nameenv/lib/python3.6/site-packages I do have a folder called ortools with some python files including pywrapplp. Do you know what I am doing wrong ?
EDIT
following request from coments:
import os
os.getcwd()
returns '/Users/imac'
which ipython
/anaconda3/bin/ipython
Installing ortools is a bit of a headache. It was some days ago, I think I finally made it with
easy_install ortools
I think it is a problem with the path. I guess because I did not install it with conda it does not find the package. I got around writting:
sys.path.append('/anaconda3/envs/env_name/lib/python3.6/site-packages/')
at the begining of my ipynb. That way I can run ortools.
You could have several python interpreter installed (python2 and python3)
So if you want to use it with ipython, which seems to be bind on python3 in your case.
First check if you have pypi package ortools installed
ipython -m pip show ortools
If you got an error it means the package is not installed.
so you can easily install it using:
ipython -m pip install --user ortools
note: We provide Pypi ortools package (64 bits) for Manylinux, Windows and MacOS.
You can also rebuild it from source https://developers.google.com/optimization/introduction/installing/source

Openpyxl ImportError in Python 3.5.2

I've tried everything recommended & still can't get openpyxl to work in Python 3. I've tried both the pip3 and "sudo apt-get install python3-openpyxl" installation methods & they seem to work fine, but when I open the python3 interpreter & type "import openpyxl", I still get the
ImportError: No module named 'openpyxl'.
It works fine in the python2 interpreter, but I just can't get get it installed for python3 & need to write my programs in python3.
I'm using Ubuntu 16.04 LTS Xenial Xerus & Python version 3.5.2. I've tried uninstalling & reinstalling the python3-openpyxl module but still get the error. Any help out there?
Thanks
I had the same problem on Mac and using:
pip3 install openpyxl
worked for me.
This works for Ubuntu 16.04 as well.
Since no one answered this, I will share my eventual work around. I backed up my files & installed Ubuntu 16.10 operating system from a bootable USB. Used Synaptic Package Manager to install openpyxl for Python3 & it is now working.
Not sure this is a bona fide solution, but it worked for my purposes.

iPython on Win8 fails to install modules

Please bear with me the total novice of Python 3 and non native English speaker.
I'm using windows 8 in iPython notebook environment, and I have problem installing modules such as Jieba. If you go to its homepage, the English version is in the bottom (however, not as updated as the Chinese version). It says it supports Python 3 as well, so I tried using git as it suggested, but it gave me this (I successfully cloned it before).
Some other things I tried as well
Using cmd to run setup.py
Using pip3 (it's another module I failed to install)
Installing easy_install (same, couldn't install it)
Do I have to use other approaches to install modules cause I'm using iPython notebook? I'm so frustrated. I'm trying to do text mining on some Chinese texts but I struggle so much with this hurdle already.
You've already cloned Jieba into your home directory (~), which is why your second attempt at cloning failed. Enter the jieba directory, and run git pull to sync any changes from the master repo. You can then run python setup.py install in that directory to install the module.
To install pip on Windows, follow the instructions in this question.

Resources