Howto enable rpy2 in python using ports? - python

I know that there are several questions touching this problem, but I can hardly figure out, if there is one solution for my problem. I am using Mac 10.6.8, MacPorts 2.1.3.
Here I refer to one discussion here on SO, where my issue seems to be addressed. This is, what I have done:
$ sudo port install py-rpy2 # seemed to be fine. A
$ python -m 'rpy2.tests' # gave the output
usr/bin/python: No module named rpy2
$ /opt/local/bin/python2.7 -m 'rpy2.tests # results in a
'Segmentation fault' # and MacOS is complaining..
After upgrading all outdated packages and
$ sudo port -f uninstall py-rpy2
$ sudo port -f install py-rpy2
... the same as above.<br>
$ sudo easy_install rpy2
throws many errors and ends with
'error: Setup script exited with error: command 'gcc-4.2' failed with exit status 1'
You can find full output here.
I have only a
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/
path, 2.7 has no
/Library/Frameworks/Python.framework/Versions/
entry.
localhost:~$ ls /opt/local/bin/python*
/opt/local/bin/python2.4
/opt/local/bin/python3.3 /opt/local/bin/python2.6
/opt/local/bin/python3.3-config /opt/local/bin/python2.6-config
/opt/local/bin/pythonw2.6 /opt/local/bin/python2.7
/opt/local/bin/pythonw2.7 /opt/local/bin/python2.7-config
/opt/local/bin/pythonw3.3
$ which python
'/usr/bin/python'
This one is Python 2.6.1.

Related

ubuntu linux gmsh gives "sh: 1: python: not found" error

I try to run a Gmsh python script from the command line (or from PyCharm or Spyder)
gmsh script.py
but I get the following error:
sh: 1: python: not found
also in the Gmsh console there is this error:
Done - 1 error : Abnormal server termination (Socket listening timeout on socket /home/user/.gmshsock2)
I did check python3 version which looks fine:
$ python3 --version
Python 3.10.4
What could be the problem?
Can anyone help to solve this ?
Thanks
Oli
The problem might be that Python is installed on your system, but that there is no symlink from python3 to python. Therefore python3 is a valid command and confirms that python is installed, but the command python is no available.
As you tagged ubuntu, i would suggest you to install the package python-is-python3 with the following command
sudo apt install python-is-python3
This package will create a symlink from /usr/bin/python to /usr/bin/python3, and therefore gmsh can execute the command python.

exec: "python": executable file not found in $PATH

since the last update to Mac OS Monterey 12.3 I get the following error message when compiling my Arduino sketch:
exec: "python": executable file not found in $PATH
Unfortunately, I have not yet been able to find out how to solve this problem.
I would be very grateful for ideas and suggestions.
Four steps are needed:
Install python3 using i.e. Brew:
brew install python
python3 is in:
/opt/homebrew/bin/python3
Link Python to python3:
sudo ln -s /opt/homebrew/bin/python3 /opt/homebrew/bin/python
Check if you can execute it from the terminal; i.e.,
python --version
Irrespective of whether you use python --version or python3 --version, it should show python 3 now.
Open terminal and execute:
open /Applications/Arduino.app
It works in my case. It looks like when Arduino is executed from the GUI, it does not read the $PATH properly, so although python is linked to python3, it does not find it.
Problem
In MacOS 12.3 Apple removed python2.7 (python) from MacOS.
Solution
What I did to solve this is link python3 to python, I wouldn't recommend it because it's sus, I would recommend you wait until Arduino IDE fixes this issue in a later build. For the time being, you could try their Web IDE: Arduino Editor
However, here are the instructions to link python3 to python:
If you don't have python3 installed, install it here in the link below:
Python Install Page
Find your path for the current version of python3 you're using
which python3
it'll show up with something like this:
/Library/Frameworks/Python.framework/Versions/3.10/bin/python3
Copy that and use it to run this command that links python 3 to python. Replace the first file path with where your python3 is.
ln -s -f INSERT_PATH_OF_PYTHON3 /usr/local/bin/python
for example:
ln -s -f /Library/Frameworks/Python.framework/Versions/3.10/bin/python3 /usr/local/bin/python

trying to solve /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError) led to bad interpreter: /usr/local/opt/python/bin/python2.7

After a brew upgrade, I couldn’t run any of my Ruby on Rails apps anymore. I got this error message:
: dlopen(/Users/ll/.rbenv/versions/2.6.2/lib/ruby/2.6.0/x86_64-darwin18/openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
Referenced from: /Users/ll/.rbenv/versions/2.6.2/lib/ruby/2.6.0/x86_64-darwin18/openssl.bundle
Reason: image not found - /Users/ll/.rbenv/versions/2.6.2/lib/ruby/2.6.0/x86_64-darwin18/openssl.bundle
So I tried
brew switch openssl 1.0.2t
solution sugests here https://stackoverflow.com/a/59184347/11410556
But couldn't find openssl 1.0.2t, my version was openssl#1.1 1.1.1h
Then I tried
brew uninstall --ignore-dependencies openssl
brew tap-new $USER/old-openssl
brew extract --version=1.0.2t openssl $USER/old-openssl
brew install openssl#1.0.2t
ln -s /usr/local/Cellar/openssl#1.0.2t/1.0.2t /usr/local/opt/openssl
suggest here: https://stackoverflow.com/a/64479513/11410556.
But when I ran
brew switch openssl 1.0.2t
I got this Error:
openssl does not have a version “1.0.2t” in the Cellar.
openssl’s installed versions
So I went for this solution
brew unlink openssl#1.1
brew link openssl#1.0.2t
And then get:
Warning: Refusing to link macOS provided/shadowed software: openssl#1.0.2t
If you need to have openssl#1.0.2t first in your PATH run:
echo ‘export PATH=“/usr/local/opt/openssl#1.0.2t/bin:$PATH”’ >> ~/.zshrc
For compilers to find openssl#1.0.2t you may need to set:
export LDFLAGS=“-L/usr/local/opt/openssl#1.0.2t/lib”
export CPPFLAGS=“-I/usr/local/opt/openssl#1.0.2t/include”
For pkg-config to find openssl#1.0.2t you may need to set:
export PKG_CONFIG_PATH=“/usr/local/opt/openssl#1.0.2t/lib/pkgconfig”
I ran the first choice :
echo 'export PATH="/usr/local/opt/openssl#1.0.2t/bin:$PATH"' >> ~/.zshrc
restart my server and now I have
omz_urlencode:2: /usr/local/bin/pygmentize: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory (edited)
Whatever I do.
I'm not used to try things I don't understand and I think I went too far.
I would be very grateful for any help to get out of this mess.
For those who would have the same problem, here's how I finally fixed it.
Regarding the Python2 error message, I set Python3 as a default Python with :
ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python
As suggested here: https://dev.to/malwarebo/how-to-set-python3-as-a-default-python-version-on-mac-4jjf
The, the error message has disappeared.
Regarding the openssl problem:
I installed the last ruby version 2.7.2 with rbenv, and upgraded my app.
Then I had a PG::ConnectionBad error.
I ran
brew postgresql-upgrade-database.
And now I’s working fine.
The simple solution suggested here put me on the way.
Thanks anothermh for your support.

Problem with macports picking up wrong python

I previously installed Python in /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6. then after the Lion update I installed it again in /System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6. But when I install any Python package using MacPorts, the installation fails with the following message:
CPATH='/opt/local/include' MACOSX_DEPLOYMENT_TARGET='10.7' LIBRARY_PATH='/opt/local/lib' F90FLAGS='-m64' CC_PRINT_OPTIONS_FILE='/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/work/.CC_PRINT_OPTIONS' LDFLAGS='-arch x86_64' FCFLAGS='-m64' OBJCFLAGS='-arch x86_64' FFLAGS='-m64' CC_PRINT_OPTIONS='YES'
:debug:build Assembled command: 'cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/work/mercurial-1.9" && /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 setup.py --no-user-cfg build'
:debug:build Executing command line: cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/work/mercurial-1.9" && /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 setup.py --no-user-cfg build
:info:build sh: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6: No such file or directory
:info:build shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/work/mercurial-1.9" && /opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6 setup.py --no-user-cfg build " returned error 127
:error:build Target org.macports.build returned: shell command failed (see log for details)
:debug:build Backtrace: shell command failed (see log for details)
while executing
"command_exec build"
(procedure "portbuild::build_main" line 8)
invoked from within
"$procedure $targetname"
:info:build Warning: the following items did not execute (for mercurial): org.macports.activate org.macports.build org.macports.destroot org.macports.install
:notice:build Log for mercurial is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_mercurial/mercurial/main.log
This happened while installing mercurial. I tried setting the default Python as the active one, but it was no use.
How can I make MacPorts use the version of Python I want? I should able to tell it this is the version and place which needs to be used.
What do you mean by you installed Python 2.6 again in /System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6? That's the location of the Apple-supplied Python 2.6 in Lion. There are also Apple-suppled Python 2.7 and 2.5 versions in that framework. Do not modify or delete anything in /System/Library! The MacPorts version is installed as before in /opt/local/.
Since upgrading to Lion, have you:
downloaded the Xcode 4.1 installer from the Mac App store and then run the installer for it (found in /Applications)?
Have you updated your MacPorts ports setup to the latest updates to support Lion?
$ sudo port selfupdate
$ sudo port -u upgrade outdated
Are you using the MacPorts mercurial port?
$ sudo port install mercurial
Have you modified your PATH to include /opt/local/bin or are you using the absolute path to the Macports Python: /opt/local/bin/python2.6
I find it best to work with virtualenv when programming python - then there's no mystery about which dependency is where, and installing packages is a breeze with pip or easy_install. If you google it, you can see a bunch of useful blog posts on how to set it up and use it effectively.

How to build sqlite for Python 2.4?

I would like to use pysqlite interface between Python and sdlite database. I have already Python and SQLite on my computer. But I have troubles with installation of pysqlite. During the installation I get the following error message:
error: command 'gcc' failed with exit status 1
As far as I understood the problems appears because version of my Python is 2.4.3 and SQLite is integrated in Python since 2.5. However, I also found out that it IS possible to build sqlite for Python 2.4 (using some tricks, probably).
Does anybody know how to build sqlite for Python 2.4?
As another option I could try to install higher version of Python. However I do not have root privileges. Does anybody know what will be the easiest way to solve the problem (build SQLite fro Python 2.4, or install newer version of Python)? I have to mention that I would not like to overwrite the old version version of Python.
Thank you in advance.
You can download and install Python to your home directory.
$ cd
$ mkdir opt
$ mkdir downloads
$ cd downloads
$ wget http://www.python.org/ftp/python/2.6.2/Python-2.6.2.tgz
$ tar xvzf Python-2.6.2.tgz
$ cd Python-2.6.2
$ ./configure --prefix=$HOME/opt/ --enable-unicode=ucs4
$ make
$ make install
Then, (if you are using bash) in your .bash_profile do
export PATH=$HOME/opt/bin/:$PATH
export PYTHONPATH=$HOME/opt/lib:$HOME/opt/lib/site-packages:$PYTHONPATH
Then, source the file to make it available
$ cd
$ source .bash_profile
$ python -V
where python -V will return the python version. If the correct version appears, any packages that you run with Python's setup.py util (assuming the developer followed the correct conventions) will install in ~/opt/lib/python2.x/site-packages directory.
Download pysqlite here, cd into the directory you downloaded to, unpack the tarball:
$ tar xzf pysqlite-2.5.5.tar.gz
then just do (if your permissions are set right for this; may need sudo otherwise):
$ cd pysqlite-2.5.5
$ python2.4 setup.py install
one error does appear in the copious output:
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/pysqlite2/test/py25tests.py", line 48
with self.con:
^
SyntaxError: invalid syntax
since as clearly shown that file is for py 2.5 tests only (with statement not present in 2.4!-). Nevertheless the install is successful:
$ python2.4 -c'import pysqlite2'
$
All this is on Mac OS X 10.5 but using python2.4 separately installed from the system-supplied Python 2.5.
The error you report doesn't tell us much -- maybe you're missing the headers or libraries for sqlite itself? Can you show us other output lines around that single error msg...?
If you don't have root privileges, I would recommend installing a more recent version of Python in your home directory and then adding your local version to your PATH. It seems easier to go that direction than to try to make sqlite work with an old version of Python.
You will also be doing yourself a favor by using a recent version of Python, because you'll have access to the numerous recent improvements in the language.
I had the same trouble with gcc failing with Ubuntu Karmic. I fixed this by installing the python-dev package. In my case, I'm working with python2.4, so I installed the python2.4-dev package. The python-dev package should work for python2.6.

Categories

Resources