I am unable to use the Ximea API (python) on linux. The documentation makes it seem like I only have to install the software package (documentation link 1/2) and the library will be available for import in any python script (documentation link 2/2). This is not the case. In windows, one can just copy-past the library from the installation folder. This is not possible in linux : the folder /opt/XIMEA does contain the python example scripts, but it does not contain the library folder itself.
Where can I find the python library folder for linux? How should I go about installing this in conda or another virtual environment?
Regards,
Jan
The answer was provided to me via the XIMEA helpdesk.
Hello,
You are right that the python xiapi is not usable after installation
without further steps to ensure so in some cases. There seems to be a
compatibility issue with the latest version of python and our software
package installation script, because of which the files aren't copied
correctly to the right location. We will work on analyzing and fixing
this, and to do so, we would appreciate if you could provide us with a
few more information. Please send us a xiCOP report, version of Python
you are using, and the output of the software package installation
script if possible. These may help us find out where exactly the
problem is. Thank you for your feedback, it is helping us greatly to
improve our products.
Meanwhile, in the next steps I'll help you copy the files manually to
get the API to work right now:
Locate the downloaded and unzipped folder "XIMEA_Linux_SP" from the first step of our software package installation guide (for me it was
on Desktop but this may differ for you).
Navigate to the /XIMEA_Linux_SP/package/api/Python/ folder and go to either "v2" or "v3" folder according to the python version you're
using. There you'll find a folder "ximea" inside of which are the
xiapi library files.
Locate the folder for python packages on your system (for me it was at /lib/python3/dist-packages/ but it may differ for you).
Copy the whole "ximea" folder from step 2. into your python packages folder (you will probably encounter permission issues, please
use sudo or similar workaround to solve this).
Your python scripts should work now.
I found the right folder by using conda info. This way I could find my conda environments in /home/jan/miniconda3/envs/<ENV NAME>/lib/python3.10/. By simply copy-pasting the ximea folder to this folder, everything worked.
Related
I want to distribute a python program on, say, Windows and/or Mac, but I don't want to give the user the headache of ensuring there is an appropriate python runtime installed on their machine. And i don't want to interfere with their machine's configuration by, let's say, requesting root privileges and installing a system-wide python runtime on their system that suits my program specifically because it's too invasive and might cause compatibility collisions with other installed versions of the runtime.
I would much rather have a self-contained executable that could be, for example, stored on a USB flash-drive, inserted into the system, and then maybe with a stepping-stone binary executable that just invokes the device-portable runtime on a python script that I provide, I could then run the program as if it were a self-contained binary executable (with only standard-library dependencies).
A link to this binary executable could be published into main-menu program lists, docks, or desktops. And it could be invoked by shell scripts or other executed-by-proxy mechanisms. Such a no-install/self-contained python program could potentially be a first-class user-invokable application. This is what I want to achieve.
I googled around for projects that provided a device-portable/mobile python installation and so far I've only found portablepython.com. Unfortunately it says the project is discontinued and no download link for the project is provided. it listed some similar projects but they all seemed defunkt or with a very different focus.
Does anyone know of an active project that is or includes such an independent/portable/mobile/no-install distribution for python?
or is there some way i could configure python's build system to build a noinstall-friendly product?
any ideas welcome. thanks for your input!
After more searching I found that Python.org publishes its own standalone-python distribution called the embeddable zip file.
This is exactly what I was searching for. It's a basic python standalone runtime that requires relatively few megabytes of storage.
I started with this embeddable distro and then cajoled a standalone copy of pip to work with it. Problem solved.
Improving upon #oreus2020's answer, you can download the embeddable zip file from here. Then, unzip the compressed file to a folder of your choice. Go to the root of your install and find python._pth file and open it in a text editor. Remove the "#" before import site(This file is the one which manages the environment of the portable install. If you want anything to be recognized by the portable python interpreter, just throw the path in here and that's it!). If you want pip, go to this page and save it in the root of your portable install and run it using the portable python interpreter like ./python get-pip.py from a commandline opened at the root of your install. Pip installed! To use the pip, do ./python -m pip <commands> from the commandline opened at the root of your install and then open the python._pth file and insert the following below the "." ./Lib/site-packages ./Scripts. Voila, you got yourself a python portable install!
My python._pth file looks like:
python39.zip
.
# Uncomment to run site.main() automatically
./Repo
./Repo/Code
./Repo/Code/cogs
./Lib/site-packages
./Scripts
import site
If you are still wondering, here is the link to the one I made for myself.
P.S. Pardon my bad English
I'm integrating a java project by using maven. This project should be pushed to a server(linux) with limited access(cannot use pip). I've added all the dependencies for my java component adding them to the pom.xml, but In part of my code I've used client/server approach to call a python script, which requires Pandas and Sklearn. Unfortunately, I've memory issue and cannot copy the entire directory of these libraries into server.
I'm afraid if maven could help me to download the python dependencies or if there is another efficient way of adding python dependencies into repository. I've done some research but couldn't find any helpful way to address that. I'm a beginner in python and I'd be happy if you could help me address that.
If limited access (Assuming you can download but cannot install) is your issue you can download Anaconda and it doesn't need to be installed with root access. It install everything to your home directory and creates a virtual environment for you. That way you can use pip too. Just make sure you call your python script with your anaconda virtual environment python.
/home/USER/anaconda2/envs/ml/bin/python script_name.py
I have Anaconda2 running smoothly on Eclipse's PyDev environment.
I have received a custom package from a colleague in the form of a folder with a "library" sub-directory that contains many ".pyc" files (which I presume are the function files) and a "init.py" file. But no matter what I do, I cannot seem to install the folder as a package.
I have tried everything posted here in the Anaconda Prompt (which I'm assuming was the correct way of implementing the instructions)
http://conda.pydata.org/docs/using/pkgs.html#install-non-conda-packages
but nothing worked.
I am very new to really working with Anaconda, Python, Eclipse, and PyDev (I have only written simple scripts with the default IDLE IDE in the past).
All I really want to be able to do is to use the package of functions given to me - even if they are not properly "installed", although that would be ideal. If anyone out there can help me with this I would be very grateful!
Pyc are precompiled files, you dont need them.
You should simply import package folder with
import folder-name
As described in: http://bugs.python.org/issue22139, the python27.dll is installed in the windows systems (in my case C:\Windows\Systems32) folder.
But I would like to know why? Why is it not installed next to the python.exe, for example in C:\Python27\?
Reason I ask: I've made a mercurial hook in python that our developers need to use to check if the commit message is valid. It checks a.o. for a valid JIRA issue number. To prevent all our developers to install python themselves and install the required modules manually (a lot of work and errorprone), I zipped the python installation and asked the developers to unzip it locally. But they can't run it, because the python27.dll is missing, or worse, they already have another minor version of python installed, and the hook will fail due to the wrong python27.dll used. Confusing.
If I just add the python27.dll (the correct version) to the zip file, it all seems to work great. So, why is it not installed in that location in the first place? What is the advantage of installing it in C:\Windows\System32?
Hope someone can explain this to me!
Thanks in advance,
Tallandtree.
I use the Anaconda Python distribution from http://continuum.io. They put python27.dll into c:\anaconda right next to its python.exe. This distribution is also superior in that you can have multiple python environments with precisely the packages you need and switch between them easily (http://conda.pydata.org/docs/using/envs.html). You can also get the package list of one of your environments and distribute it to others.
I recommend this Python distribution over the one from python.org and Enthought, because of this issue.
.dlls are quite windows-specific files. I imagine you will have shared object (.so) files for LINUX/UNIX-specific Python stuff? You said your developer's couldn't run it, because they didn't have the correct DLL (i.e. the one relevant to their Python installation).
Also, the advantage of installing it to System32 is that it's in the default PATH. Additionally, if any other application is internally using Python and require access to the .dll file, and also NOT reference your Python directory, they will probably be looking for a location that "Actually" exists (I wanted to say guaranteed to exist, but......never mind). That location would be `C:/windows/Systems32'.
I found it to work just fine to put python27.dll in the Python directory (c:\Python27 or wherever). As long as it's in the PATH, it seems to work. I did this for a "relocatable" installation of Python. I can copy the installation directory to a Windows machine that has no Python installed, set the PATH to include that directory, and run Python, including all the libraries I had installed with pip install on the original machine.
Does anyone know where I could find this file on Ubuntu?
On my machine it's in:
/usr/share/doc/python2.7/examples/Tools/scripts/diff.py
However, it'll vary a little depending on your distrib and how up to date you are. But there's a really handy little tool called 'locate' that you can use to quickly find stuff on your machine.
locate diff.py | grep Tools
Gives me
/usr/share/doc/python2.7/examples/Tools/scripts/diff.py
/usr/share/doc/python2.7/examples/Tools/scripts/ndiff.py
/usr/share/doc/python3.1/examples/Tools/scripts/diff.py
/usr/share/doc/python3.1/examples/Tools/scripts/ndiff.py
As I have two versions of Python installed. I put it through grep, as sometimes locate can match quite a lot.
If you're sure that you have a file on your machine, but locate isn't finding it, you might need to update your database, which is done with the 'updatedb' command, as root. So, just run
sudo updatedb
and get a coffee (or two if you have a slow machine/very full drive) and then try again.
This command
$ locate "Tools/scripts/diff.py"
will find the location of the file if it's installed. This depends on the database generated regularly by the updatedb command (this usually runs as a cron job, but can also be invoked manually)
FWIW, I just checked my Ubuntu installation (10.04LTS) and didn't find it. Perhaps only Python versions 2.7+ have this (the default version that came with this install is still v2.6.5)
I needed to know this for a different environment, namely Linux running an Amazon Machine Image (AMI). I installed Python 3.5 via "yum" but couldn't find the Tools/scripts directory using find/locate, etc., or any other "yum" package which included it.
So in the end I cloned the python source tree mirror:
git clone https://github.com/python-git/python python
This downloads the Tools/scripts folder which I then moved to some standard location. I needed the "2to3" program from "scripts" and this worked. There is also a "clone or download" link at that URL where the package can be downloaded in the usual way if git is not available.
I couldn't find an easy way to install the Tools/scripts via "yum" on AMI Linux, which would still be my preference.