Pipenv uses the wrong lib directory - pipenv

I have a project using Python 3.10.4, i. e., the Pipfile has,
[requires]
python_version = "3.10.4"
I installed Python 3.10.4 using pyenv install 3.10.4 and now pyenv versions returns,
* system (set by /home/username/.config/pyenv/version)
3.10.4
Now when I run pipenv install I get,
Creating a virtualenv for this project…
Using /home/username/.config/pyenv/versions/3.10.4/bin/python3 (3.10.4) to create virtualenv…
⠋created virtual environment CPython3.10.4.final.0-64 in 82ms
creator CPython3Posix(dest=/home/username/.local/share/virtualenvs/project-2ZeatEXR, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/username/.local/share/virtualenv)
added seed packages: pip==20.3.4, pkg_resources==0.0.0, setuptools==44.1.1, wheel==0.34.2
activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
Virtualenv location: /home/username/.local/share/virtualenvs/project-2ZeatEXR
Pipfile.lock not found, creating…
Locking [dev-packages] dependencies…
from . import utils
File "/usr/lib/python3/dist-packages/pipenv/vendor/requests/utils.py", line 27, in <module>
from .cookies import RequestsCookieJar, cookiejar_from_dict
File "/usr/lib/python3/dist-packages/pipenv/vendor/requests/cookies.py", line 172, in <module>
class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'
The line Using /home/username/.config/pyenv/versions/3.10.4/bin/python3 (3.10.4) indicates that pipenv has found the right Python version and is using it to create the virtual environment but then when creating the lock file, observe that it uses the lib: /usr/lib/python3/dist-packages/pipenv/vendor/requests/utils.py directory is of the system installation. Which then causes the error since the system's lib is for Python 3.9.
Maybe this is a bug or maybe I have missed some config. Could someone see what is going wrong here?

Related

Can't install libgtk2.0-dev_2.24.31-2_arm64.deb on Renesas R-Car H3 (H3ULCB)

I am trying to run object detection algorithm (which is using OpenCV 2.4.13.7) on H3ULCB. It is giving libGTK as shown below
root#h3ulcb:/media/2.4.13_algo_target_# ./main_
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or [ 1976.641753] audit: type=1706
Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvWaitKey, fil7
terminate called after throwing an instance of 'cv::Exception'
what(): /media/2.4.13.7_pckage/modules/highgui/src/window.cpp:567: error: (-2) The function is not implemented. Rebuild the library with Wiy
Aborted (core dumped)}
To solve the error , I tried to install libGTK package (libgtk2.0-dev_2.24.31-2_arm64.deb) on H3ULCB, but its not getting installed to the target.
* pkg_extract_data_file_names_to_stream: Failed to extract data.tar.gz from package '/media/libgtk2.0-dev_2.24.31-2_arm64.deb'.
* pkg_get_installed_files: Error extracting file list from /media/libgtk2.0-dev_2.24.31-2_arm64.deb.
* opkg_install: Cannot install package libgtk2.0-dev.
BSP and SDK for H3ULCB are build using yocto, details are listed below:
Yocto version: 2.23
Poky: 2.1.3
The same error is resolved on the native Linux (Ubuntu16.04) by installing the libgtk2.0 library from apt-get manager. But package manager apt and dpkg is not getting installed on the target. I tried to add these managers in the yocto layers while building the image.
Currently Available package manager on H3ULCB is OPKG. Since OPKG works on .IPK packages but not .IPK packages on available for libgtk2.0, I have converted the .deb package to a .IPK package .While executing the .IPK package on H3ulcb:
root#h3ulcb:/media# opkg install libgtk2.0-dev_2.24.31-2_arm64.ipk
Collected errors:
* open_outer: Failed to open package 'libgtk2.0-dev_2.24.31-2_arm64.ipk': Unrecognized archive format
* pkg_extract_control_file_to_stream: Failed to extract control.tar.gz from package 'libgtk2.0-dev_2.24.31-2_arm64.ipk'.
* pkg_init_from_file: Failed to extract control file from libgtk2.0-dev_2.24.31-2_arm64.ipk.
In the package libgtk2.0-dev_2.24.31-2_arm64.deb, there are 3 files
control.tar.gz
data.tar.xz
debian-binary
while executing the .deb file on H3ULCB, the error showed data.tar.gz instead of data.tar.xz as given below:
pkg_extract_data_file_names_to_stream: Failed to extract data.tar.gz from package '/media/libgtk2.0-dev_2.24.31-2_arm64.deb'.
I have converted data.tar.xz to data.tar.gz, but how to pack these files 3 files back to .deb package?

How to include Eigen in C++ library after installing libeigen3-dev package

I am trying to build OpenCV from Source (master branch) using cmake.
I installed Eigen package via apt-get.
sudo apt-get install libeigen3-dev
It was successfully installed, and cmake prints that eigen 3.3.4 is installed.
Eigen: YES(ver 3.3.4)
But when I did 'make', it showed the error
/opencv/modules/core/include/opencv2/core/private.hpp:66.12: fatal error: Eigen/Core: No such file or directory
# include <Eigen/Core>
^~~~~~~~~~~~
compilation teminated.
I found the same question on superuser.
So as the answer did, I have changed cmake/OpenCVFindLibsPerf.cmake from line 44 to 59.
After I have commented out line 46-48 and 59,
and changed find_package(Eigen3 QUIET) in line 44 to find_package(Eigen3 3.0.0), it works.
And this problem only happens on OpenCV 4.0 version.
When I install OpenCV 3.4.6 version(tag 3.4.6 on github), this problem does not occur.

How to make OpenCV 3.2 package built from source available in Anaconda environment?

I have built OpenCV 3.2 from source with Visual Studio 2017 under Windows 10, which generated a file cv2.cp36-win_amd64.pyd in the build directory, and also copied it to C:\Users\fanta\Anaconda3\Lib\site-packages.
But now, after entering an Anaconda environment for Python 3.6, python doesn't find the package, see transcript below (error at the bottom):
C:\Users\fanta>conda create -n py36 python=3.6
Fetching package metadata ...........
Solving package specifications: .
Package plan for installation in environment C:\Users\fanta\Anaconda3\envs\py36:
The following NEW packages will be INSTALLED:
pip: 9.0.1-py36_1
python: 3.6.1-2
setuptools: 27.2.0-py36_1
vs2015_runtime: 14.0.25123-0
wheel: 0.29.0-py36_0
Proceed ([y]/n)?
#
# To activate this environment, use:
# > activate py36
#
# To deactivate this environment, use:
# > deactivate py36
#
# * for power-users using bash, you must source
#
C:\Users\fanta>activate py36
(py36) C:\Users\fanta>python
Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
>>>
If instead I try to import the cv2 package from outside any Anaconda environment, I get a different error, see below:
(py36) C:\Users\fanta>deactivate py36
C:\Users\fanta>python
Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
>>>
How can I make the built cv2 package available to be imported in an Anaconda environment?
Thanks!
It turned out the right place for the cv2.cp36-win_amd64.pyd file is (for my py36 Anaconda environment):
C:\Users\fanta\Anaconda3\envs\py36\Lib
Then I got a ImportError: DLL load failed: The specified module could not be found.
To fix the ImportError:
added the directory with built DLLs for OpenCV to the PATH
environment variable (C:\opencv32\build\install\x64\vc15\bin in my
case);
set OPENCV_DIR (to C:\opencv32\build\install\x64\vc15 in my
case).
Finally I installed numpy and matplotlib in the Anaconda environment.
Now OpenCV 3.2 built from source with Visual Studio 2017 works.

Library not loaded: /usr/local/lib/libhdf5.9.dylib

After "brew upgrade", I found I cannot use Pytables on my Mac.
import tables as tb
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-29-57032f570037> in <module>()
----> 1 import tables as tb
/usr/local/lib/python2.7/site-packages/tables/__init__.py in <module>()
80
81 # Necessary imports to get versions stored on the cython extension
---> 82 from tables.utilsextension import (
83 get_pytables_version, get_hdf5_version, blosc_compressor_list,
84 blosc_compcode_to_compname_ as blosc_compcode_to_compname,
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/tables/utilsextension.so, 2): Library not loaded: /usr/local/lib/libhdf5.9.dylib
Referenced from: /usr/local/lib/python2.7/site-packages/tables/utilsextension.so
Reason: image not found
I found that instead of having libhdf5.9.dylib in the directory, I have libhdf5.10.dylib now.
I can uninstall and install hdf5 without a problem and I also tried to reinstall tables.
I'm not sure how to solve this problem.
You need to reinstall tables. If you are using a recent version of pip, you also need to make sure you don't use a cached version of pytables that was built against the old libhdf. You can do this with pip install -U --force-reinstall --no-binary tables tables.
Problem solved by installing the developing version from GitHub:
pip install git+https://github.com/PyTables/PyTables.git#develop#egg=tables

How to refer to data files in a pkg-config package with the autotools and pkg-config?

I'm attempting to create a Homebrew formula for gtk-mac-integration. Running make in bindings/python/gtkosx_application fails:
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file '/usr/local/Cellar/gtk-mac-integration/2.0.7/share/pygobject/2.0/codegen/h2def.py': [Errno 2] No such file or directory
make[3]: *** [gtkosx_application.defs] Error 2
This is because the Makefile tries to find the h2def.py file in the wrong location:
gtkosx_application.defs: $(headers)
$(PYTHON) $(datadir)/pygobject/2.0/codegen/h2def.py $(headers) > $#
It is clear to me why this is failing: $(datadir) points to the share directory of the package that is to be installed (gkt-mac-integration). Because Homebrew installs all packages into their own prefix (/usr/local/Cellar/...), it is not the same for gtk-mac-integration and pygobject.
I know it is possible to find out where the pygobject data directory is located using
pkg-config --variable=datadir pygobject-2.0
I don't suppose the correct fix is to replace datadir in the Makefile with the string above? How should I adjust configure.ac and Makefile.am to make this work properly?
Yeah, that sounds like a bug in the build system.
You can use the inreplace facility to patch this up. Insert this after def install:
inreplace %w[bindings/python/gtkmacintegration/Makefile.am
bindings/python/gtkmacintegration/Makefile.in
bindings/python/gtkosx_application/Makefile.am
bindings/python/gtkosx_application/Makefile.in],
'$(datadir)/pygobject', |
%x[pkg-config --variable=datadir pygobject-2.0].chomp + '/pygobject'
(I tried this out. The formula builds after that.)
You should report this upstream. They should change their build system to sort this out in their configure script.

Resources