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

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]

Related

3rd party libraries of Python cant be used on MSYS2 terminal, how to use them in MSYS2 terminal?

OS: windows 10
I install python3.9, pip install many 3rd party packages and use them well on both Pycharm and CMD terminal;
Later, I install MSYS2 and then I tpye 'python' on the terminal of MSYS2 and get into python terminal; it seems well until now. When I import sth, getting the warning "No module named 'xxx'" which can be imported well on Pycharm or CMD terminal.
so I guess the path of 3rd party packages not be included for MSYS2, how to resovle it?
Here is the standard way to use Python 3 and pip in MSYS2:
Select the "MSYS2 MinGW 64-bit" shortcut or run mingw64.exe to start a MinGW 64-bit shell. (32-bit should work too.)
Run pacman -S $MINGW_PACKAGE_PREFIX-{python3,python3-pip} to install both Python 3 and pip.
Run pip install PKGNAME to install a package you need.
Run python path/to/script.py to run your script.
I tested these instructions just now. I was able to run pip install pyserial and then I was able to run a script that started with import serial.

'pip' is not recognized as an internal or external command, operable program or batch file. Cant find pip file

I have tried to install libraries using pip but my console doesnt recognize as a command. I checked the python/scripts folder and there was no ppip.exe in the folder. I reinstalled Python 3.6 a couple of times but I havent been able to use it. I tried it on another computer and pip installed itself with python 3.6.
I've seen answers that say to open a Python shell, then insert
python -m pip install 'packagename'
but i tried this and the shell marked invalid syntax at the end of writing pip
on linux(ubuntu)
#for default
sudo apt install python-pip
#for version specific
python2.7
sudo apt install python2-pip
for 3.x
sudo apt install python3-pip
for windows
In some terminals try to use
$py -m pip install packagename
Of course you first have to import pip with
$import pip
if pip is installed the following will work for sure
open a python shell then
import pip
pip.main(['install', 'packagename'])
replace the packagename with the package you want to install
because of the path problem try to use absolute paths ( in windows beginning with drive letter i.e. C:/.../.../pip.exe). in batch script it is generally good idea to use absolute paths. Alternatively check if your path has to be fixed : https://docs.python.org/3/using/windows.html
( http://jelly.codes/articles/python-pip-module/ )
Operating systems search for executables in the system path. I.e. windows knows by default where its own executables are located because the directory is in the system path, however when new software is installed that contains executables like pip the system path has to be edited to inform windows ( or linux ) where the new executables are located. The path is an environment variable. This is also valid for other languages and programs like java ( Environment variables for java installation ) ,...
Now your problem very likely is that the directory where the pip.exe executable is stored is not part of your windows path. This has to be fixed like in https://docs.python.org/3/using/windows.html, chapter 3.3. Configuring Python
How to run Pip commands from CMD

Cannot open Gnome Terminal or install packages using pip without sudo in Ubuntu

I have been trying to install python packages and change the permissions of a folder using chmod. I can't remember which folder as it was just the one which the terminal said I did not have permissions for. I cannot even open it from x-term due to a python error(using python 2 print instead of 3?)
Since doing this I have been unable to open the gnome-terminal using the icon, the cursor becomes a laoding icon for a moment and then dissapears without opening the program.
I am also unable to use pip to install programs without using the program in sudo mode
Furthermore I cannot use the import command in python. Note that I have intalled scipy to my machine
Does anyone know what I have done and how I can revert it?
wrt to the import failing, pip installs modules into the /site-packages directory of your python directory. So I think the issue is that pip installed it in a different python directory than the directory that the system is using when you type python3. I would highly recommend using virtualenv when installing packages - this way you can keep your python executable as well as the dependencies all in one place. However, some packages are required to be installed in the system's python directory. wrt pip requiring you to use sudo, how did you install pip? Usually I do sudo apt-get install python3-pip

xlrd, xlwt with sagemath

I want to use xlrd, xlwt, xlutils with sagemath. I have installed them in my system's Python(2.7.3) but sage environment is not recognizing them. Getting following error when I try to import with sage
ImportError: No module named xlrd`
But without sage its working fine. Any idea how can I make them work inside sage?? I am using Ubuntu 12(quantal),32 bits and Sage Version 5.8 with Python 2.7.5(sage's Python).
Faced same problem with Tkinter too but solved it using sudo apt-get install tk8.5-dev got solution form http://www.sagemath.org/doc/faq/faq-usage.html#how-to-get-sage-s-python-to-recognize-my-system-s-tcl-tk-install
But what for other libraries?
I tried to install them manually inside /usr/lib/sagemath/local/lib/python2.7/site-packages/ folder by putting tar files then extract them and then sudo python setup.py install
but still not working.
Rather than installing them with the system Python, install them with Sage's Python: you can either do sage --sh: this starts a subshell with various environment variables set appropriately for use with Sage, in particular $PATH will have $SAGE_ROOT/local/bin first. Then install the packages with python setup.py install etc. Or you can just run Sage's Python directly with sage --python setup.py install ....
Sage does not use the python installed in your system. It uses its own copy of python so while working with sage programs you would have to run the programs from terminal using this command
$ sage --python <Python_File>
Similarly sage does not uses the modules installed in the system's python. The Modules need to be installed under sage libraries. You have downloaded and extracted the folder right but used a wrong command. Now go again in the xlrd extracted folder and use this command.
$ sage --python setup.py install
Now Everything should work.
Cheers

How do I install py2app onan off-internet PC

I have downloaded py2app, but the problem is that easy install seems to be an online installation, yet I am installing this on an off-line pc, so can't use easy install. I expected to be able to download an EXE file or MSI file to install it on my PC using a normal procedure to install a Python package, because the python packages that I have installed before have been from self running files.
The downloadable version of Py2app does not include any such self running file. It tells me to type $python setup.py install. Where do I type this? Into what command line?
If you're running Windows (and it seems that you're) you will need to go to the Run window (Win + R) and...
type cmd
type python setup.py install
...to begin the instalation.
If you doesn't have Python on your PATH, the use:
C:\PythonXY\python.exe setup.py install (for example, in Python 2.7 use C:\Python27\python.exe setup.py install).
Also maybe you need to specify the setup.py path so you should do:
C:\PythonXY\python.exe C:\Some\Path\setup.py install.
If you're running any Linux distro then just open the terminal and type that command.
Hope it helps!
You need to download an install the following packages (in this order):
altgraph
macholib
modulegraph
py2app
All of them can be installed by first downloading and extracting the archive and then run "python setup.py install" with the current working directory set to the directory containing the setup.py file.
However... You appear to want to install py2app on a Windows PC, and that won't work because py2app does not support Windows (it cannot cross "compile" a Mac application bundle).

Categories

Resources