can't find snap7 library - linux - linux

I'm running Rapbian on a Raspberry Pi Revision B.
I downloaded the module python-snap7 as instructed on this webpage: Snap7 Installation
I tried it twice: One time using pip and another doing it manually.
However, I installed it then via setup.py build and then setup.py install.
If i try to create a client, I get the following error:
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import snap7
>>> c = snap7.client.Client()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/snap7/client.py", line 29, in __init__
self.library = load_library()
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 48, in load_library
return Snap7Library(lib_location).cdll
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 40, in __init__
raise Snap7Exception(msg)
snap7.exceptions.Snap7Exception: can't find snap7 library. If installed, try running ldconfig
I did the following after getting this error:
I added some lines to the file so it looks like the following:
include /etc/ld.so.conf.d/*.conf
include /usr/local/lib/python2.7/dist-packages/snap7-full-1.2.1/
include /usr/local/lib/python2.7/dist-packages/snap7-full-1.2.1/release/Linux/ARMHF/Raspberry/
include /usr/local/lib/python2.7/dist-packages/snap7-full-1.2.1/src/lib/
include /usr/local/lib/python2.7/dist-packages/snap7-python/build/lib.linux-armv6l-2.7/snap7/
include /usr/local/lib/python2.7/dist-packages/snap7-python/
Then I issued the command sudo ldconfig to update the cache file /etc/ld.so.cache, but the error stays :(
Is it right to have the include instruction in fornt of each line?
Is there any kind of critical error I just don't see?
Which library do i need to include ?
I just thought of the provided ones over here: SourceForge Link. I have choosen the first .tar.gz package.
Sorry for my english and thanks in advance!

Looks like you didn't install SNAP7 library (it's not included in python-snap7)
To use snap7 library on Raspberry Pi with python-snap7 wrapper you need to do followed steps:
Download SNAP7 library
for example: snap7-full-1.2.1
in Pi command line:
wget http://sourceforge.net/projects/snap7/files/1.2.1/snap7-full-1.2.1.tar.gz/download
Unzip downloaded file
in Pi command line:
tar -zxvf snap7-full-1.2.1.tar.gz
Compile library for raspberry (arm_v6_linux.mk is used for RPI 1. For RPI 2 use arm_v7_linux.mk)
in Pi command line:
cd snap7-full-1.2.1/build/unix && sudo make -f arm_v6_linux.mk all
Copy compiled library to lib directories
in Pi command line:
sudo cp ../bin/arm_v6-linux/libsnap7.so /usr/lib/libsnap7.so
sudo cp ../bin/arm_v6-linux/libsnap7.so /usr/local/lib/libsnap7.so
(optional) Install python pip if you don't have it
in Pi command line:
sudo apt-get install python-pip
Install python wrapper for SNAP7 lib
in Pi command line:
sudo pip install python-snap7

You have not installed snap7 library that is why you have this problem.
In order to solve this problem I suggest you to install it in a proper way. What I describe below is a horrible hacky way, but I have not found time to make better.
For a quick fix you can
download this: http://sourceforge.net/projects/snap7/files/1.1.0/
unar it, and
in folder 'build/unix'
run command make -f x86_64_linux.mk all
then cp ../../build/bin/x86_64_linux /usr/local/lib/
then modify common.py in order to manually point to your '.so' file in 'init' function
I added this line at start of this function : lib_location = "/usr/local/lib/libsnap7.so"

I got a solution:
sudo chown -R $USER /usr/local/lib/python2.7/dist-packages/snap7
To give permissions to edit files in the snap7 library directory.
Then edit the complaining files, below the init with an additional line like this:
def __init__(self):
lib_location='/usr/local/lib/libsnap7.so' # add this line here

Related

wand.image Import Error: shared library not found. You probably had not installed ImageMagick library

I am attempting to use the PDFPlumber library, which uses Wand's image format. However, upon trying to run:
from wand.image import Image
I get this error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wand/api.py", line 151, in <module>
libraries = load_library()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wand/api.py", line 140, in load_library
raise IOError('cannot find library; tried paths: ' + repr(tried_paths))
OSError: cannot find library; tried paths: ['/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWandHDRI.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWandHDRI-2.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-7.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-7HDRI.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-7HDRI-2.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-7.Q8.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-7.Q8HDRI.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-7.Q8HDRI-2.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-7.Q16.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-7.Q16HDRI.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-7.Q16HDRI-2.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-6.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-6HDRI.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-6HDRI-2.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-Q16.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-Q16HDRI.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-Q16HDRI-2.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-Q8.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-Q8HDRI.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-Q8HDRI-2.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-6.Q16.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-6.Q16HDRI.dylib', '/opt/homebrew/opt/imagemagick#6/lib/lib/libMagickWand-6.Q16HDRI-2.dylib']
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/wand/api.py", line 177, in <module>
'Try to install:\n ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
brew install freetype imagemagick
I first tried installing normally:
pip3 install wand
brew install imagemagick
Then, I tried using the method listed here, and tried the following:
pip3 install wand
brew uninstall imagemagick
brew install imagemagick#6
brew unlink imagemagick && brew link imagemagick#6
export MAGICK_HOME="/opt/homebrew/opt/imagemagick#6/"
export PATH="/opt/homebrew/opt/imagemagick#6/bin:$PATH"
but am still getting the same error.
I also tried the solutions listed here and confirmed that I am running 64-bit python 3.7 as mentioned here. How can I fix this? I'm especially confused because after running:
cd /opt/homebrew/opt/imagemagick#6/lib
ls
I can see that /opt/homebrew/opt/imagemagick#6/lib/libMagickWand-6.Q16.dylib is where Wand expects it to be (listed in the tried paths in the error above):
ImageMagick libMagickCore-6.Q16.7.dylib libMagickWand-6.Q16.a
libMagick++-6.Q16.9.dylib libMagickCore-6.Q16.a libMagickWand-6.Q16.dylib
libMagick++-6.Q16.a libMagickCore-6.Q16.dylib libMagickWand-6.Q16.la
libMagick++-6.Q16.dylib libMagickCore-6.Q16.la pkgconfig
libMagick++-6.Q16.la libMagickWand-6.Q16.7.dylib
I faced the same issue when tried running Wand on M1 mac, even though the same steps worked on x86 system. Solution that worked for me is to install ImageMagick via brew in x86 mode:
alias brew86="arch -x86_64 /usr/local/bin/brew"
brew86 install imagemagick
# get imagemagick installation path
brew86 info imagemagick
export MAGICK_HOME=/usr/local/Cellar/imagemagick/7.1.0-49_1
export PATH="$MAGICK_HOME/bin:$PATH"
I also face same issue on Mac M1 machine. I only set the ENV variables
like this after checking brew info imagemagick command. There is no need to reinstall imagemigick as arch -x86_64 at least for me on Mac M1 OS Monterey 12.6
export MAGICK_HOME=/opt/homebrew/Cellar/imagemagick/7.1.0-51
export PATH="$MAGICK_HOME/bin:$PATH"
and it working fine.

How to have virtualbox python bindings working with chosen Python version?

I'm using Python3 bindings for virtualbox (pyvbox). It works with the initial python3 version of my system which is 3.7. Now, I would like to use the very same bindings with python3.8. I have installed all needed python3.8 packages, but i get this error:
$ python3
Python 3.8.0 (default, Oct 28 2019, 16:14:01)
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import virtualbox
>>> _vbox = virtualbox.VirtualBox()
m=VBoxPython3_8 x=No module named 'VBoxPython3_8'
m=VBoxPython3 x=No module named 'VBoxPython3'
m=VBoxPython x=/usr/lib/virtualbox/VBoxPython.so: undefined symbol: _Py_ZeroStruct
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home//.local/lib/python3.8/site-packages/virtualbox/library_ext/vbox.py", line 22, in __init__
manager = virtualbox.Manager()
File "/home//.local/lib/python3.8/site-packages/virtualbox/__init__.py", line 145, in __init__
self.manager = vboxapi.VirtualBoxManager(mtype, mparams)
File "/usr/local/lib/python3.8/dist-packages/vboxapi/__init__.py", line 989, in __init__
self.platform = PlatformXPCOM(dPlatformParams)
File "/usr/local/lib/python3.8/dist-packages/vboxapi/__init__.py", line 750, in __init__
import xpcom.vboxxpcom
File "/usr/lib/virtualbox/sdk/bindings/xpcom/python/xpcom/vboxxpcom.py", line 78, in <module>
raise Exception('Cannot find VBoxPython module (tried: %s)' % (', '.join(_asVBoxPythons),))
Exception: Cannot find VBoxPython module (tried: VBoxPython3_8, VBoxPython3, VBoxPython)
I have found that these modules have to be in /usr/lib/virtualbox, which currently contains only these files:
$ ls /usr/lib/virtualbox/ | grep VBoxPython
VBoxPython2_7.so
VBoxPython3_7m.so
VBoxPython.so
These .so files are installed via the virtualbox package. However, I cannot manage to have neither VBoxPython3.so nor VBoxPython3.8.so by reinstalling. I have looked at the virtualbox code and it seems that the c macro PY_VERSION_HEX indicates 3.7 instead of 3.8, which would be caused by the wrong Python.h header being included.
How can I force virtualbox package to include /usr/include/python3.8/Python.h instead of /usr/include/python3.7/Python.h ?
Uninstalling python3.7 is not an option.
The pyvbox package docs (redirected from pyvbox) imply that the .so files aren't installed by it. But, they do note that the Python package is dependent on the VirtualBox SDK. Which, in turn, recommend installing the SDK to the system Python manually. That latest seems irky, especially when done outside a package manager but maybe they know better.
Digging around, I found the .so files are owned by the OS package virtualbox. In other words, virtualbox must be installed with Python3.8 support.
# Who owns/provides this file (use your dist equivalent or duckduckgo)
$ yay -Fy /usr/lib/virtualbox/VBoxPython3_8.so
...
usr/lib/virtualbox/VBoxPython3_8.so is owned by community/virtualbox 6.1.6-1
I suggest you reinstall the virtualbox package for your distribution. Installing the latest version will provide the latest .so library files Virtualbox supports.
Let's test the theory
# Install Virtualbox and the Virtualbox SDK
yay -S virtualbox virtualbox-sdk python-virtualbox
# Assert we aren't getting an error
$ python -c "import virtualbox; _vbox = virtualbox.VirtualBox(); print('Success!')"
Success!
Otherwise, if the package doesn't include 3.8 support, you'll have to compile it yourself while making sure LD_LIBRARY_PATH points to your Python 3.8 dev libraries. But, I strongly recommend against this. It is infinitely better to work along with your package manager and benefit from upstream work.
Good luck!

Unable to use cv_bridge with ROS Kinetic and Python3

I had a computer vision project on Ubuntu 14.04 with ROS indigo and python3, then I had to move on Ubuntu 16.04 with ROS kinetic. Here I ran into multiple issues:
1) I installed opencv, but couldn't import it in python3, the error message was:
Traceback (most recent call last):
File "test.py", line 2, in <module>
import cv2
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so:
undefined symbol: PyCObject_Type
What I figured out is just rename cv2.so
cd /opt/ros/kinetic/lib/python2.7/dist-packages/
sudo mv cv2.so cv2_ros.so
Then I was able to import cv2 and use it
2) Then I couldn't import rospy, but installation of python3-catkin-pkg-modules and python3-rospkg-modules fixed that problem
3) Finally I ran into an issue with cv_bridge it says:
[ERROR] [1520780674.845066]: bad callback: <bound method ViewsBuffer.update of <__main__.ViewsBuffer object at 0x7f5f45a07f28>>
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "test.py", line 48, in update
im = self.bridge.imgmsg_to_cv2(im, "bgr8")
File "/opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/core.py", line 163, in imgmsg_to_cv2
dtype, n_channels = self.encoding_to_dtype_with_channels(img_msg.encoding)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/core.py", line 99, in encoding_to_dtype_with_channels
return self.cvtype2_to_dtype_with_channels(self.encoding_to_cvtype2(encoding))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/cv_bridge/core.py", line 91, in encoding_to_cvtype2
from cv_bridge.boost.cv_bridge_boost import getCvType
ImportError: dynamic module does not define module export function (PyInit_cv_bridge_boost)
I believe the problem is in the cv_bridge_boost.so file.
I also tried to build cv_bridge from https://github.com/ros-perception/vision_opencv, but it automatically builds for python2.7, I was trying to modify CMakeLists.txt a little bit to specify python3 there, but I don't have much experience with CMakeLists, so it didn't work. I also tried to copy cv_bridge module to my project folder, but it didn't change much and it still points on that cv_bridge_boost.so file.
Another thing to mention is that cv_bridge works fine with python2.7, but my project requires python3.5.
You are right, you should build cv_bridge with python3.
You can do it with passing
-DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so
args to cmake.
Or, if you are using catkin to build packages, you can do next steps:
# `python-catkin-tools` is needed for catkin tool
# `python3-dev` and `python3-catkin-pkg-modules` is needed to build cv_bridge
# `python3-numpy` and `python3-yaml` is cv_bridge dependencies
# `ros-kinetic-cv-bridge` is needed to install a lot of cv_bridge deps. Probaply you already have it installed.
sudo apt-get install python-catkin-tools python3-dev python3-catkin-pkg-modules python3-numpy python3-yaml ros-kinetic-cv-bridge
# Create catkin workspace
mkdir catkin_workspace
cd catkin_workspace
catkin init
# Instruct catkin to set cmake variables
catkin config -DPYTHON_EXECUTABLE=/usr/bin/python3 -DPYTHON_INCLUDE_DIR=/usr/include/python3.5m -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so
# Instruct catkin to install built packages into install place. It is $CATKIN_WORKSPACE/install folder
catkin config --install
# Clone cv_bridge src
git clone https://github.com/ros-perception/vision_opencv.git src/vision_opencv
# Find version of cv_bridge in your repository
apt-cache show ros-kinetic-cv-bridge | grep Version
Version: 1.12.8-0xenial-20180416-143935-0800
# Checkout right version in git repo. In our case it is 1.12.8
cd src/vision_opencv/
git checkout 1.12.8
cd ../../
# Build
catkin build cv_bridge
# Extend environment with new package
source install/setup.bash --extend
And
$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cv_bridge.boost.cv_bridge_boost import getCvType
>>>
If you encountered an next error
CMake Error at /usr/share/cmake-3.5/Modules/FindBoost.cmake:1677 (message):
Unable to find the requested Boost libraries.
Boost version: 1.58.0
Boost include path: /usr/include
Could not find the following Boost libraries:
boost_python3
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
Call Stack (most recent call first):
CMakeLists.txt:11 (find_package)
It is because CMake tries to find libboost_python3.so library, but in ubuntu it is libboost_python-py35.so(/usr/lib/x86_64-linux-gnu/libboost_python-py35.so), so you should change line
find_package(Boost REQUIRED python3)
to
find_package(Boost REQUIRED python-py35)
in file src/vision_opencv/cv_bridge/CMakeLists.txt and rebuild package.
I have anaconda3 installed in my system and I face a similar issue while using cv_bridge. When I try to build using catkin build cv_bridge it throws up an error. I use python3.7 from conda. My catkin cofig command is:
catkin config -DPYTHON_EXECUTABLE=/home/akashbaskaran/anaconda3/bin/python3 -DPYTHON_INCLUDE_DIR=/home/akashbaskaran/anaconda3/include/python3.7m -DPYTHON_LIBRARY=/home/akashbaskaran/anaconda3/lib/libpython3.7m.so
Solution:
There are a couple of things which I did and the issue got resolved.
since anaconda is being used, the executables and include directorires should be the one inside your current virtual enviroment. -DPYTHON_EXECUTABLE=/home/akashbaskaran/anaconda3/envs/tf/bin/python3.6 -DPYTHON_INCLUDE_DIR=/home/akashbaskaran/anaconda3/envs/tf/include/python3.6m -DPYTHON_LIBRARY=/home/akashbaskaran/anaconda3/envs/tf/lib/libpython3.6m.so
e
I was having build issues when I tried catkin build cv_bridge. If you face a similar issue, delete all folders except src. Then run catkin_make from the terminal (make sure you are present inside catkin_workspace).
source the current workspace source devel/setup.bash
Now
import cv2
from cv_bridge.boost.cv_bridge_boost import getCvType
should work without an error.
My basic environment:Ubuntu 18.04 and ROS melodic.
I am compiling cv_bridge in conda's virtual environment(python3.7), and I have the same problem as #Jibril. When I catkin build cv_bridge, I get 1 package successful and 3 packages skipped / blacklisted.
The command I use is
# 1
catkin init
# 2
catkin config \
-DPYTHON_EXECUTABLE=/home/zed/anaconda3/envs/yolov5/bin/python3.7 \
-DPYTHON_INCLUDE_DIR=/home/zed/anaconda3/envs/yolov5/include/python3.7m \
-DPYTHON_LIBRARY=/home/zed/anaconda3/envs/yolov5/lib/libpython3.7m.so
# 3
catkin config --install
# 4
catkin build cv_bridge
Then I found the error message about the --install-layout parameter by looking at the log file in the {ws}/log folder.
Referring to the solution in the issue, I added -DSETUPTOOLS_DEB_LAYOUT=OFF to the original command and finally finished compiling.
The command I modified is
# 1
catkin init
# 2
catkin config \
-DPYTHON_EXECUTABLE=/home/zed/anaconda3/envs/yolov5/bin/python3.7 \
-DPYTHON_INCLUDE_DIR=/home/zed/anaconda3/envs/yolov5/include/python3.7m \
-DPYTHON_LIBRARY=/home/zed/anaconda3/envs/yolov5/lib/libpython3.7m.so \
-DSETUPTOOLS_DEB_LAYOUT=OFF
# 3
catkin config --install
# 4
catkin build cv_bridge
When you need to use the compiled cv_bridge in another ROS workspace, you only need to execute source {PATH_cv_bridge_ws}/install/setup.bash --extend, then source {PATH_current_ws}/devel/setup.bash.
If the above solution doesn't work for you, you can also try some of the alternatives to cv_bridge proposed in this issue!!

Xcode 9.1 export fails with "The /usr/bin/xattr tool may be damaged"

Xcode 9.0.1 crash when export ipa or upload to App Store in MacOS 10.13.1.
After upgraded to Xcode 9.1 (9B55), it shows error as below when export.
Stripping extended attributes failed.
"/usr/bin/xattr -crs /var/folders/mm/h01jykrs7gv9w7jjb0yt609w0000gp/T/XcodeDistPipeline.Uay/Root/Payload/GitSmartHome.app" exited with a non-zero status. The /usr/bin/xattr tool may be damaged.
It seems xattr was damaged, and when run xattr in Terminal, it prompts below error.
xattr
Traceback (most recent call last):
File "/usr/bin/xattr-2.7", line 7, in <module>
from pkg_resources import load_entry_point
File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 3019, in <module>
File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 3003, in _call_aside
File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 3032, in _initialize_master_working_set
File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 655, in _build_master
File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 963, in require
File "build/bdist.macosx-10.13-intel/egg/pkg_resources/__init__.py", line 849, in resolve
pkg_resources.DistributionNotFound: The 'xattr==0.6.4' distribution was not found and is required by the application
How to fix it or re-install xattr?
Xcode always looks at /usr/bin/xattr, regardless of your paths (as you might have a working xattr installed elsewhere).
Typing in /usr/bin/xattr gave this output:
/usr/bin/xattr
Traceback (most recent call last):
File "/usr/bin/xattr-2.7", line 7, in <module>
from pkg_resources import load_entry_point
File "build/bdist.macosx-10.12-intel/egg/pkg_resources/__init__.py", line 72, in <module>
File "build/bdist.macosx-10.12-intel/egg/packaging/requirements.py", line 59, in <module>
TypeError: __call__() takes exactly 2 arguments (1 given)
You need to get your system's python happy again. I seem to have broken mine at some point. Not sure how.
I ran the following and got a screen full of errors.
/usr/bin/python -m pip install -U setuptools
Afterwards, I ran /usr/bin/xattr again it it was silent. This seems to be the test for whether it's healthy.
My XCode exports now without the error.
The crux is that your /usr/bin/xattr will give you some kind of error, whether it's permissions or some other python/setup issue. You need to fix that to have your builds working again.
Edit:
For those with permission issues, run this:
sudo chown -R $USER:$(id -g) /Users/$USER/Library/Python
I had this problem too. It turned out that this started happening after I zapped /Library/Python/2.7 and with it I deleted /Library/Python/2.7/site-packages/Extras.pth. Here's what was in it:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC
The first of these directories contains an old version of xattr that still supports -c option (something I could not resolve by installing xattr v0.6.4 myself).
➜ /usr/bin/xattr
python version 2.7.14 can't run /usr/bin/xattr. Try the alternative(s):
/usr/bin/xattr-2.6 (uses python 2.6)
/usr/bin/xattr-2.7 (uses python 2.7)
Run "man python" for more information about multiple version support in
Mac OS X.
➜ cd /usr/bin
➜ sudo rm xattr
➜ sudo ln -s xattr-2.7 xattr
➜ /usr/bin/xattr
#Ren gave a good hint, following his thought, with the help of Ned Deli's Answer, solved the problem here.
My situation: python 2.7 as default system version(use pyenv normally). /usr/bin/xattr always tempts to call /usr/bin/xattr-2.7, which won't be successful. Calling xattr-2.6 works fine, forcing /usr/bin/xattr call xattr-2.6 leads to "option -c not recognized" while the XCode trying to call xattr -crs ....
Solution: After using command: $defaults write com.apple.versioner.python Version 2.6 Xcode can finally distribute my app.
You can set your system default python whenever you like back to 2.7 with:
$unset VERSIONER_PYTHON_VERSION
If your mac throws you an error like "option -c not recognized" you can still try to launch the original source code "xattr python tool" using a command like this:
sudo python /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/xattr/tool.pyc -cr /Applications/[Application].app
It works for me ;)
I just ran into the same issue and resolved it with:
/usr/bin/python -m pip install xattr==0.6.4
reinstall xcode-select, open terminal and type
xcode-select --install

Using virtualenv with python3 in openSuSE

I am experiencing a problem when using virtualenv in openSuSE 12.3 with Python3:
I installed the python3 and python3-devel packages.
Then I installed the newest distribute and pip and finally virtualenv using pip.
When I try to create a virtualenv I get the following error:
$ virtualenv-3.3 venv01
Using base prefix '/usr'
New python executable in venv01/bin/python3.3
Also creating executable in venv01/bin/python
Installing distribute.........................................................................................................................................................................................................................................................................................................................................................................................................done.
Installing pip....
Complete output from command /home/user/venv01/bin/python3.3 -x /home/user/venv01/bin/easy_install /usr/local/lib/pytho...ort/pip-1.3.1.tar.gz:
/home/user/venv01/bin/python3.3: can't open file '/home/user/venv01/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv-3.3", line 9, in <module>
load_entry_point('virtualenv==1.9.1', 'console_scripts', 'virtualenv-3.3')()
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 979, in main
no_pip=options.no_pip)
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 1094, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 667, in install_pip
filter_stdout=_filter_setup)
File "/usr/local/lib/python3.3/site-packages/virtualenv.py", line 1057, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /home/user/venv01/bin/python3.3 -x /home/user/venv01/bin/easy_install /usr/local/lib/pytho...ort/pip-1.3.1.tar.gz failed with error code 2
Running it with -vvv yields some interesting output that shows that distribute
is extracted to <venv>/local/lib/python3.3/site-packages/.
I wonder why distribute is not installed into <venv>/lib/python3.3/site-packages/?
Does anyone have an idea why this happens and how I can use virtualenv in
openSuSE without compiling python3 myself?
[now fixed in latest patches from opensuse]
[oh! i just realised you are the same person as the original link. sorry. but i will leave this as it is a top result for google search on this issue (was searching myself for any update) so it may help others.]
this is a known issue, discussed at https://forums.opensuse.org/english/get-technical-help-here/applications/484475-using-virtualenv-python-3-a.html and with an open bug at https://bugzilla.novell.com/show_bug.cgi?id=809831
the only work-around i know of is to install everything yourself. it's not so hard, and i describe what is necessary at http://www.acooke.org/cute/GettingPyt0.html
basically:
install python 3.3 from source (do an "altinstall" to install as /usr/local/bin/python3.3)
fix the lib issue (link lib_dynload from /usr/local/lib64/python3.3 to /usr/local/lib/python3.3)
install distutils
install virtualenv
then you can use python3.3 and virtual-env-3.3 etc as expected.

Resources