简体   繁体   中英

How to install Python packages from python3-apt in PyCharm on Windows?

I'm on Windows and want to use the Python package apt_pkg in PyCharm.

On Linux I get the package by doing sudo apt-get install python3-apt but how to install apt_pkg on Windows?

There is no such package on PyPI.

There is no way to run apt-get in Windows; the package format and the supporting infrastructure is very explicitly Debian-specific.

Not quite what you're looking for, but it's possible to use apt-offline on Windows to download the packages. However, you still need a Linux box to generate the sig file.

For example:

python apt-offline set vim-offline.sig --install-packages vim

Will not work:

ERROR: This argument is supported only on Unix like systems with apt installed

However, if you run that command on Linux first, the following command should work on Windows:

python apt-offline get vim-offline.sig -d vim

apt-offline source is available here: https://github.com/rickysarraf/apt-offline

To build it, simply run:

python setup.py build
python setup.py install

I got it to run with Python 3.8.2 on Windows 10.

Note: in the end of the day, you're just downloading a .deb package and it is simply an ar file containing a tarball and can be extracted with tools like 7-zip. However, if it contains a Linux binary (vim example), there isn't much you can do with it on Windows.

One can use chocolatey the equivalent for windows.

https://chocolatey.org/install

add it to the windows PATH environment

C:\ProgramData\chocolatey\bin

Restart python or anaconda. And is ready to use.

To install packages inside a .py script or a Jupiter notebook, use the syntax below

!choco install [package name]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM