How to install python-dev on MSYS2? - python

Posts I've viewed:
How to Install Python Development Tools on MSYS2
I'm trying to run pyinstaller in msys2, but I'm getting the following error:
OSError: Python library not found:
python38.dll, libpython3.8.dll, libpython38.dll, libpython3.8m.dll, libpython38m.dll
This would mean your Python installation doesn't come with proper library files.
This usually happens by missing development package, or unsuitable build parameters of Python installation.
* On Debian/Ubuntu, you would need to install Python development packages
* apt-get install python3-dev
* apt-get install python-dev
* If you're building Python by yourself, please rebuild your Python with `--enable-shared` (or, `--enable-framework` on Darwin)
Here's what I've tried installing in MSYS2 using pacman:
mingw-w64-x86_64-python
libgpgme-python
mingw-w64-i686-python3
base-devel
Unfortunately, I get the same error every time. I've also tried setting my path variable to every place I could think of that might have these libraries, and even one spot that I know has libpython3.8.dll but it was no help.
Thanks in advance!

It looks like
pip install python-dev-tools
was what I was looking for.

Related

How to setup Python virtual environment with bindings for gstreamer?

I would like to use gstreamer library (1.0+) inside my python code. As they mention on their website they offer python bindings, but unfortunately they do not provide any additional information on how to get it up and running.
Can someone please provide a step by step instructions on how to install all the required package (preferably with pip) in order to use gstreamer inside a python virtual environment. A minimal working example would also be highly appreciated.
ps: I am working on Ububtu 18.04
In order to use gstreamer with python bindings a PyGObject package must be installed.
The setup procedure is the following:
Open a terminal and enter your virtual environment
Execute sudo apt install libgirepository1.0-dev gcc libcairo2-dev pkg-config python3-dev gir1.2-gtk-3.0 to install the build dependencies and GTK
Execute pip3 install pycairo to build and install Pycairo
Execute pip3 install PyGObject to build and install PyGObject
A more comprehensive guide can be found here:
https://pygobject.readthedocs.io/en/latest/getting_started.html
Check their examples:
https://gitlab.freedesktop.org/gstreamer/gst-python/-/tree/master/examples
Everything to get started should be in there.

Can't fix "zipimport.ZipImportError: can't decompress data; zlib not available" when I type in "python3.6 get-pip.py"

I was trying to install Django. Turns out that course's teacher said that we will be working with Python 3.6
I install Python 3.6. Now it's my default, it somewhat replaced the last version I had; which is Python 3.5.
Everything ok until that. But when I want to install Django doing
"pip3 install django", it tells me that the module is already satisfied and therefore installed.
I run "python3" command into my terminal. It runs Python 3.6. I try to import Django, and boom... "No module named 'django'".
Then I realized pip3 was actually installing my modules into Python 3.5 and not 3.6. So what I do is to install pip in Python 3.6.
I download get-pip.py and proceed to execute it with Python 3.6 typing in "python3.6 get-pip.py".
Here is when the damn "zipimport.ZipImportError: can't decompress data; zlib not available" goes in. I've tried a ton of things and no one of them fixed the %^$! problem. I'm really tired.
What I have already tried:
python3.6 -m pip install django, which output is "/usr/local/bin/python3.6: No module named pip"
apt install zlib, which output is "E: Unable to locate package zlib"
apt install zlib1g-dev, which says that it's already installed; the problem persists though.
I also came across this problem (while creating a simple installer for pyenv). Here's how I solved it for Mac and Linux:
Ubuntu 20.04, 18.04
You need the zlib development files, and probably zlib itself too:
sudo apt install -y zlib1g-dev zlibc
If you're missing zlib, it's likely that the next problem you'll run into is with openssl, so it's probably best to get that now as well:
sudo apt install -y libssl-dev
sudo apt install -y libssl1.1 || sudo apt install -y libssl1.0
macOS
I believe this comes with XCode CLI Tools (or at least I didn't have to custom install it Big Sur):
xcode-select --install
For me it worked in RHEL:
$ yum install zlib-devel
Suggested solutions (installing zlib1g-dev or zlib-devel) seem to resolve the issue in most cases. Here is one edge case I've encountered recently: whatever you are trying to run might use zlib via symlink which might be broken.
In my case I was trying to run a build of a 3rd-party software which already had python and all necessary libs being emebedded into it. It was packaged as a tar.gz archive. Unpacking the archive on a Windows machine and then copying the contents to another linux machine destroyed all the symlinks (if you do ls -l in a folder with symlinks you would see that all of them have size 0 and do not point to anything). Copying tar.gz to the linux machine directly and unpacking it there resolved the issue.
P.S. I know it's an edge case scenario but it took me and one more developer quite a while to figure it out so I think it's worth mentioning here, just in case someone gets as unlucky as I got.
Its solves my issue for centos 7.6 :-
yum install zlib-deve

'bz2 is module not available' when installing Pandas with pip in python virtual environment

I am going through this post Numpy, Scipy, and Pandas - Oh My!, installing some python packages, but got stuck at the line for installing Pandas:
pip install -e git+https://github.com/pydata/pandas#egg=pandas
I changed 'wesm' to 'pydata' for the latest version, and the only other difference to the post is that I'm using pythonbrew.
I found this post, related to the error, but where is the Makefile for bz2 mentioned in the answer? Is there another way to resolve this problem?
Any help would be much appreciated. Thanks.
You need to build python with BZIP2 support.
Install the following package before building python:
Red Hat/Fedora/CentOS: yum install bzip2-devel
Debian/Ubuntu: sudo apt-get install libbz2-dev
Extract python tarball. Then
configure;
make;
make install
Install pip using the new python.
Alternative:
Install a binary python distribution using yum or apt, that was build with BZIP2 support.
See also: ImportError: No module named bz2 for Python 2.7.2
I spent a lot of time on the internet and got a partial answer everywhere. Here is what you need to do to make it work. Follow every step.
sudo apt-get install libbz2-dev Thanks to Freek Wiekmeijer for this.
Now you also need to build python with bz2. Previously installed python won't work. For that do following:
Download stable python version from https://www.python.org/downloads/source/ then extract that Gzipped source tarball file. You can use wget https://python-tar-file-link.tgz to download and tar -xvzf python-tar-file.tgz to extract it in current directory
Go inside extracted folder then run following commands one at a time
./configure
make
make install
This will build a python file with bz2 that you previously installed
Since this python doesn't have pip installed, idea was to create a virtual environment with above-built python then install pandas using previously installed pip
You will see python file in the same directory. Just create a virtual environment.
./python -m env myenv (create myenv in the same directory or outside it's your choice)
source myenv/bin/activate (activate virtual environment)
pip install pandas (install pandas in the current environment)
That's it. Now with this environment, you should be able to use pandas without error.
pyenv
I noticed that installing Python using source takes a long time (I am doing it on i7 :/ ); especially the make and make test...
A simpler and shorter solution was to install another version of Python (I did Python 3.7.8) using pyenv, install it using these steps.
It not only saved the problem of using multiple Python instances on the same system but also maintain my virtual environments without virtualenvwrapper (which turned buggy on my newly setup ubuntu-20.04).

Install python-pyparsing 1.4.2-1.1_all.deb on debian etch with apt-get

I am trying to install python-pyparsing onto my debian etch but running into issues when I run sudo apt-get install python-pyparsing_1.4.2-1.1_all.deb. Seems to give me this error here
Reading package lists... Done
Building dependency tree... Done
W: Couldn't stat source package list http://archive.debian.org etch/main Packages (/var/lib/apt/lists/archive.debian.org_debian_dists_etch_main_binary-i386_Packages) -stat (2 No such file or directory)
W: You may want to run apt-get update to correct these problems
E: Couldn't find package python-pyparsing_1.4.2-1.1_all.deb
I've run apt-get update but it tells me again same error and then
E: Some index files failed to download, they have been ignored, or old ones used instead.
UPDATE
I now have apt-get install -f trying to install my python-pyparsing_1.4.2-1.1_all.deb file and it reads back:
Reading package lists... Done
Building dependency tree... Done
E: Couldn't find package python-pyparsing_1.4.2-1.1_all.deb
I'm not getting the run apt-get update anymore. Is there a directory I need to have this in? I have it inside my /mnt/hgfs/ directory at this time.
Any help is greatly appreciated on how to get pyparsing installed for this debian
If you're trying to install Pyparsing for development purposes (that is, you're writing a program that uses Pyparsing, rather than just trying to install another deb that has Pyparsing as a dependency), you shouldn't use your distribution's package manager.
Instead, create a virtualenv (http://www.virtualenv.org/en/latest/) to develop your application, and use the supplied distribute dependency management system.
Virtualenvs are self-contained Python environments that don't have access to any of the Python modules you have installed system-wide (and can even, if you want, use a different version of Python than your system). Instead, they download and install (in themselves) all the dependencies of the programs/libs you want to run within them.
The advantages to that approach are the following:
You're not limited to the libs and versions present in your distribution's package manager (which are often outdated -- for example, Pyparsing is currently at version 2.0.1, unlike Debian's 1.4.2).
You can ensure that the dependencies of your program/lib are correctly documented in its setup.py, instead of working by sheer luck because you have something installed system-wide that you forgot about 6 months ago.
Furthermore, those will be downloaded and installed automatically with one line: python setup.py install, which greatly simplifies your program's installation and deployment.
Yes, you should use a virtualenv in your production environment too. Why? Because if you're running different programs with different sets (and versions) of dependencies in the same environment (that is, your computer's actual Python installation), installing a new version of a lib because program A requires it might break program B which relies on an old version.
Your program/lib's dependency management will work in any OS or distro (even Windows) without any extra effort.
It's easy to uninstall the crappy libraries that you tried once and decided weren't good for your project: if pip uninstall xxxx doesn't work, just delete the virtualenv and recreate it -- it is, after all, only one line to get all your deps back.
The name of the package is python-pyparsing. You are using the package file name, which is composed of the package name, version, and architecture, with a .deb extension to boot.
The correct command line is
sudo apt-get install python-pyparsing
The package toolchain takes care of finding a suitable version for your architecture, and downloading it from a suitable repository. (apt-cache policy python-pyparsing will tell you which versions are available.)
If you require this specific version, use
sudo apt-get install python-pyparsing=1.4.2-1.1
provided it is available from one of the Apt sources you have configured.
(If you have a deb file which you have downloaded, you can install that with dpkg:
sudo dpkg -i path/to/python-pyparsing_1.4.2-1.1_all.deb
but you should normally never need to do this. dpkg doesn't download missing dependencies or do much anything you don't specifically ask it to.)
Just open Ubuntu software centre, reinstall ubuntu-extras-keyring and then run sudo apt-get update from terminal.

Unable to locate package libboost-python1-40-dev?

I'm installing sorl-thumbnail and one of its requirements is libboost-python1.40-dev.
When I try to install it with sudo apt-get install libboost-python1.40-dev, I'm getting E:Unable to locate package libboost-python1.40-dev. How can I install this package?
You probably have a different version of the package.
What does
apt-cache search boost-python
give you? That's the name of the package you need to install (use the dev variant if you get multiple results).
If your package version is lower than 1.40, you can do two things:
cross your fingers and hope things will work
upgrade your system, or find a way to add the updated package to your package manager
If your package version is larger than 1.40, you should be reasonably safe, unless there was some awkward backwards-incompatible change.
Maybe a wrong version?
This works for me:
sudo apt-get install libboost-python1.49-dev

Categories