I am planning to use Metis for drawing some networks and graphs using Python. I downloaded Metis from here. For installing the Python wrapper, I followed the instructions given here, but when I run the easy_install command like:
$ easy_install metis
I get this error:
RuntimeError: Could not locate METIS dll. Please set the METIS_DLL environment variable to its full path.
From the second link above, I understand that I have to specify the full path to some 'METIS shared library' file in the METIS_DLL environment variable. But I don't know what the file is called and where it is located or how I should specify the path in an environment variable.
According to my research on Google, I found out that the file might be called 'libmetis.so' but I don't have any file of that name. Could someone give me a clue on this?
Any help would be appreciated, thanks.
I assume that you are working on Linux (because of the .so suffix) and that you have downloaded, compiled and installed the source code linked in the page. User libraries are installed in /usr/lib or /usr/local/lib and their subdirectories. Note that you might have lib64 or lib32 also, so try searching there. Try also in /opt and in the site-packages Python external modules folder, although it's usually placed inside /usr/lib. Entering locate libmetis.so at the command line might help.
If you have downloaded that package and not compiled yet, then you simply don't have that file. Read BUILD.txt or BUILD-windows.txt and follow the instructions.
Please note that this question belongs on Superuser rather than on Stackoverflow.
Related
I am working on making a python wrapper for some existing code using CFFI, but I'm getting stuck with packaging and distribution for Linux.
I've loosely followed the example here: https://github.com/wolever/python-cffi-example
And I've read this question as well: How to use shared dynamic libraries with python-cffi (in linux)?
I can get the python packager to install the .so file into the site-packages folder, but I can't get Python to locate it there (results in an ImportError: cannot open shared object file).
If I manually copy the .so file to /usr/lib or /usr/local/lib everything works fine, but I can't get the python package to copy files there (absolute paths don't work in a wheel) and that doesn't seem like the right answer anyway.
I also looked at modifying LD_LIBRARY_PATH in my python startup code, but that doesn't take effect for the current process only for new ones so that doesn't work either.
How can I distribute a .so file with a python package in a way that it can be located when the package is imported?
I'm trying to install OpenCV into my python environment (Windows), and I'm almost all of the way there, but still having some issues with autocomplete and Pycharm itself importing the library. I've been through countless other related threads, but it seems like most of them are either outdated, for prebuilt versions, or unanswered.
I'm using Anaconda and have several environments, and unfortunately installing it through pip install opencv-contrib-python doesn't include everything I need. So, I've built it from source, and the library itself seem to be working fine. The build process installed some things into ./Anaconda3/envs/cv/Lib/site-packages/cv2/: __init__.py, some config py files, and .../cv2/python-3.8/cv2.cp38-win_amd64.pyd. I'm not sure if it did anything else.
But here's where I'm at:
In a separate environment, a pip install opencv-contrib-python both runs and has autocomplete working
In this environment, OpenCV actually runs just fine, but the autocomplete doesn't work and Pycharm complains about everything, eg: Cannot find reference 'imread' in '__init__.py'
Invalidate Caches / Restart doesn't help
Removing and re-adding the environment doesn't help
Deleting the user preferences folder for Pycharm doesn't help
Rebuilding/Installing OpenCV doesn't help
File->Settings->Project->Project Interpreter is set correctly
Run->Edit Configuration->Python Interpreter is set correctly
So my question is: how does Pycharm get or generate that autocomplete information? It looks like the pyd file is just a dll in disguise, and looking through the other environment's site-packages/cv2 folder, I don't see anything interesting. I've read that __init__.py has something to do with it, but again the pip version doesn't contain anything (except there's a from .cv2 import *, but I'm not sure how that factors in). The .whl file you can download is a zip that only contains the same as what 'pip install' gets.
Where does the autocomplete information get stored? Maybe there's some way to copy it from one environment to another? It would get me almost all the way there, which at this point would be good enough I think. Maybe I need to rebuild it with another flag I missed?
Got it finally! Figures that would happen just after posting the question...
Turns out .../envs/cv/site-packages/cv2/python-3.8/cv2.cp38-win_amd64.pyd needed to be copied to .../envs/cv/DLLs/. Then PyCharm did it's magic and is now all good.
Alternatively add the directory containing the .pyd file to the interpreter paths.
I had exactly this problem with OpenCV 4.2.0 compiled from sources, installed in my Conda environment and PyCharm 2020.1.
I solved this way:
Select project interpreter
Click on the settings button next to it and then clicking on the Show paths for selected interpreter
adding the directory containing the cv2 library (in my case in the Conda Python library path - e.g. miniconda3/lib/python3.7/site-packages/cv2/python-3.7). In general check the site-packages/cv2/python-X.X directory)
FindPythonLibs.cmake is somehow finding Python versions that don't exist/were uninstalled.
When I run find_package(PythonLibs 3 REQUIRED) CMake properly finds my Python3.6 installation and adds its include path, but then I get the error
No rule to make target 'C:/Users/ultim/Anaconda2/libs/python27.lib', needed by 'minotaur-cpp.exe'. Stop.
This directory doesn't exist, and I recently uninstalled Anaconda and the python that came with it. I've looked through my environment variables and registry, but find no reference to this location.
Would anyone know where there might still be a reference to this location?
Since the "REQUIRED" option to find_package() is not working, you can be explicit about which Python library using CMake options with cache variables:
cmake -DPYTHON_INCLUDE_DIR=C:\Python36\include -DPYTHON_LIBRARY=C:\Python36\libs\python36.lib ..
I'm working on a script that will plot data onto a map using the Basemap library. I'm trying to import Shapely as well for use in this same script. I'm working with Anaconda2 for Python2.7 in a Windows 7 environment. I used conda install to download the tar.bz2 file from the Conda Packages site (using Windows command line) and it looked like it all installed correctly.
When I open Pycharm and look at my accessible site-packages, I can see this package. However, when I try to use it within my script, I get an error saying that the package does not exist. I ran the script through the debugger to see if it would shed any more light, but I got the same error. Here's a screenshot of my available site packages when I go to Settings-->Project Interpreter from within Pycharm.
Screenshot of PyCharm site packages available
Is there something special I need to do in order to access this package from within a fresh Python file? I was trying to say "import shapely" or "import osx-64-shapely", but both give me the same "package does not exist" error message. I've been able to successfully use other third-party libraries within Python, so I'm not quite sure what the error is here....
I'm new to SO - if you need more details or there's some piece of info I didn't include, please let me know. Thank you for your help!
EDIT: I am NOT asking what the difference is between conda and pip, or how to use pip within PyCharm. I have used both successfully before to install third-party libraries. What I am asking is what might cause a third-party library that appears to have installed successfully from the command line become inaccessible from within PyCharm when I attempt to import it.
I'm not familiar with Shapely but I was astonished to see the name osx-64-shapely as a site-package for your python installation which is in windows 7. Are you sure you downloaded the right file? :)
I am implementing the reddit.com source code on ubuntu karmic 9.10.
I have followed all the steps and in one step where i am using paster command it throws an error.
$paster shell example.ini
File "/usr/local/lib/python2.6/dist-packages/Pylons-0.9.6.2-
py2.6.egg/pylons/middleware.py", line 11, in
from webhelpers.rails.asset_tag import javascript_path
ImportError: No module named rails.asset_tag
I have checked for the version for webhelpers, its the latest installed.
Could anybody tell me that by installing another version of webhelpers will solve this problem?
Or Shall i modify the code?
Its a reddit.com source code written in python, using pylons framework.
I am unable to decide that whether by installing any previous version of webhelpers helps or shall i modify the code.
If there is anybody who have implemented the reddit.com website please help me or suggest me the best way.
thanks
SIA
You need to ensure that all the libraries needed by your Reddit clone are on Python's module search path. There are a lot of different ways to accomplish this. The easiest is probably to just use setuptools' easy_install command to install them (though this is my own personal least favorite way to install Python libraries, and also opens new cans of worms in the form of "Why not use distribute or pip instead?").
The next easiest way is probably to download and unpack the source code for the libraries you need and either a) setup.py install them or b) add their directories to your $PYTHONPATH or sys.path variables.
The documentation linked above has more info on how to control the module search path.