how to import gimp in python3 script? - python-3.x

Sorry for a noob question, but I can't seem to find gimp's install command.
$ pip3 install pgimp
throws the below error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-tt98fv7k/pgimp/setup.py'"'"'; __file__='"'"'/tmp/pip-install-tt98fv7k/pgimp/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /tmp/pip-install-tt98fv7k/pgimp/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-tt98fv7k/pgimp/setup.py", line 42, in <module>
check_python2_installation()
File "/tmp/pip-install-tt98fv7k/pgimp/setup.py", line 38, in check_python2_installation
'At least one of the following packages is missing in the python2 installation: ' + ', '.join(requirements)
__main__.GimpInstallationException: At least one of the following packages is missing in the python2 installation: numpy, typing
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I do not know if it is possible to add Gimp into python, but if you have installed gimp beta with flatpack (I tried it on Ubuntu and OpenSuse) you can run a interactive bash or python shell in witch you can find gimp:
flatpak run --command=python org.gimp.GIMP//beta
In this way it open a python shell that can import gimp like into a plugin.
If you want to run a script you can use a bash shell inside it you can run for example python -m ensurepip and start to install with pip your dependencies:
flatpak run --command=bash org.gimp.GIMP//beta
I find more information about that on Create Python3 Plugin for GIMP: The basics and on Some ideas and tools to develop Python 3.8 plugins for GIMP 2.99.4

Related

Cannot install modules using pip - it gives an error

I uninstalled Python 3.8 and then installed Python 3.9.
Now, when I try to install any module using pip:
pip install pygame
It shows this error:
ERROR: Command errored out with exit status 1:
command: 'c:\users\acer\appdata\local\programs\python\python39\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Acer\\AppData\\Local\\Temp\\pip-install-s3fy0toj\\pygame\\setup.py'"'"'; __file__='"'"'C:\\Users\\Acer\\AppData\\Local\\Temp\\pip-install-s3fy0toj\\pygame\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Acer\AppData\Local\Temp\pip-pip-egg-info-lgmfm8yh'
cwd: C:\Users\Acer\AppData\Local\Temp\pip-install-s3fy0toj\pygame\
Complete output (17 lines):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...
Download prebuilts to "prebuilt_downloads" and copy to "./prebuilt-x64"? [Y/n]Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\Acer\AppData\Local\Temp\pip-install-s3fy0toj\pygame\setup.py", line 194, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\Users\Acer\AppData\Local\Temp\pip-install-s3fy0toj\pygame\buildconfig\config.py", line 210, in main
deps = CFG.main(**kwds)
File "C:\Users\Acer\AppData\Local\Temp\pip-install-s3fy0toj\pygame\buildconfig\config_win.py", line 576, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\Users\Acer\AppData\Local\Temp\pip-install-s3fy0toj\pygame\buildconfig\download_win_prebuilt.py", line 302, in ask
reply = raw_input(
EOFError: EOF when reading a line
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I tried uninstalling and installing Python again, but still no luck. I had no problem like this when I was using Python 3.8
When I tried installing Django, it worked but then I tried installing Pandas and it did not work.
Please help.
I think there are some compatibility issues with python3.9.
For more information,you can check this link.
https://github.com/pygame/pygame/issues/2145

Unable to import tkSnack from Python3

I'm trying to import tkSnack from Python3 in Debian 10.
I have already installed tkSnack from apt:
apt-get install python3-tksnack
Anyway, when trying to import tkSnack module frome python3:
ModuleNotFoundError: No module named 'tkSnack'
I have also tried to install tkSnack from pip, but the following error message appears:
ERROR: Command errored out with exit status 1:
command: /home/cooper/anaconda3/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-x8rnbcp1/snack/setup.py'"'"'; __file__='"'"'/tmp/pip-install-x8rnbcp1/snack/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-x8rnbcp1/snack/pip-egg-info
cwd: /tmp/pip-install-x8rnbcp1/snack/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-x8rnbcp1/snack/setup.py", line 47
print GCC_VERSION
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(GCC_VERSION)?
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
It's strange that, when importing tkSnack in python2.7 all works well!
Does anyone have any idea about this? Thaks!
There're 2 separate problems in your question so it'd be better if you've asked 2 different questions.
You installed the package with system package manager apt-get but tried to use with local anaconda environment. That doesn't work: packages installed with system package managers should be used with system-installed python. To install packages into virtual environments (including anaconda) use conda or pip.
SyntaxError in print means the code is for Python2 only; in Python3 print becomes a function and requires parenthesizes: print(GCC_VERSION). It seems you installed a wrong, Python2-only version of the package and is trying to use it with Python3. Uninstall it and reinstall with code update for Python3.

Unable to install wsgiref in python 3.x

I can't install wsgiref in python 3. I got these errors.
I am using python 3, but I can't install wsgiref
I tried pip install wsgiref and pip install wsgiref==0.1.2
E:\CodeWork\Machine Learning\SWATI-The-Assistant-master\SWATI-The-Assistant-master>pip install wsgiref==0.1.2
Collecting wsgiref==0.1.2
Using cached https://files.pythonhosted.org/packages/41/9e/309259ce8dff8c596e8c26df86dbc4e848b9249fd36797fd60be456f03fc/wsgiref-0.1.2.zip
ERROR: Command errored out with exit status 1:
command: 'c:\program files\python37\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\hp\\AppData\\Local\\Temp\\pip-install-h2ydr_0e\\wsgiref\\setup.py'"'"'; __file__='"'"'C:\\Users\\hp\\AppData\\Local\\Temp\\pip-install-h2ydr_0e\\wsgiref\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\hp\AppData\Local\Temp\pip-install-h2ydr_0e\wsgiref\pip-egg-info'
cwd: C:\Users\hp\AppData\Local\Temp\pip-install-h2ydr_0e\wsgiref\
Complete output (8 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\hp\AppData\Local\Temp\pip-install-h2ydr_0e\wsgiref\setup.py", line 5, in <module>
import ez_setup
File "C:\Users\hp\AppData\Local\Temp\pip-install-h2ydr_0e\wsgiref\ez_setup\__init__.py", line 170
print "Setuptools version",version,"or greater has been installed."
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Setuptools version",version,"or greater has been installed.")?
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.```
The reason the pip 3 install is erroring is the syntax of one of the print statements in the setup process is old python 2 style with no parentheses. The good news is that wsgiref is already included in the python 3 library by default. Fire up a python 3 shell and try typing 'import wsgiref', that should succeed with no error.

Installing package using Pip install on MacOS 10.15

Using Python3.7.3, MacOS 10.15
Can't install package - feather
tried pip3 install feather
returns error:
ERROR: Command errored out with exit status 1:
command: /usr/local/opt/python/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/vl/pzz3tlxx6_d5p38wth_1nnwr0000gn/T/pip-install-3p9h1fgs/feather/setup.py'"'"'; __file__='"'"'/private/var/folders/vl/pzz3tlxx6_d5p38wth_1nnwr0000gn/T/pip-install-3p9h1fgs/feather/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /private/var/folders/vl/pzz3tlxx6_d5p38wth_1nnwr0000gn/T/pip-install-3p9h1fgs/feather/
Complete output (31 lines):
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.14.tar.gz
Traceback (most recent call last):
File "/private/var/folders/vl/pzz3tlxx6_d5p38wth_1nnwr0000gn/T/pip-install-3p9h1fgs/feather/distribute_setup.py", line 143, in use_setuptools
raise ImportError
ImportError
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
All I'm trying to do is avoid this error in spyder
ModuleNotFoundError: No module named 'feather'
Can someone help me as to why I'm running into an issue like this
Looks like setuptools is missing.
Try pip3 install setuptools
this is where the error is reported.
# Setuptools 0.7b and later is a suitable (and preferable)
# substitute for any Distribute version.
try:
pkg_resources.require("setuptools>=0.7b")
return
except (pkg_resources.DistributionNotFound,
pkg_resources.VersionConflict):
pass
if not hasattr(pkg_resources, '_distribute'):
if not no_fake:
_fake_setuptools()
raise ImportError
What is the version number of setuptools?

install pymssql and cython fails on Mac OSX

I have python project. In the project i have requirements.txt file. while trying to install dependency from requirements file i am getting below error. I am using mac machine, python 3.6, Cython==0.29.3,pymssql==2.1.4
ERROR: Command errored out with exit status 1:
command: /Users/user_name/.virtualenvs/test/bin/python3.6 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/rz/f3lsfyh154s_r7fggcqx57q80000gp/T/pip-install-bz2kcaud/pymssql/setup.py'"'"'; __file__='"'"'/private/var/folders/rz/f3lsfyh154s_r7fggcqx57q80000gp/T/pip-install-bz2kcaud/pymssql/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /private/var/folders/rz/f3lsfyh154s_r7fggcqx57q80000gp/T/pip-install-bz2kcaud/pymssql/
Complete output (7 lines):
/Users/user_name/.virtualenvs/test/lib/python3.6/site-packages/setuptools/dist.py:45: DistDeprecationWarning: Do not call this function
warnings.warn("Do not call this function", DistDeprecationWarning)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/rz/f3lsfyh154s_r7fggcqx57q80000gp/T/pip-install-bz2kcaud/pymssql/setup.py", line 88, in <module>
from Cython.Distutils import build_ext as _build_ext
ModuleNotFoundError: No module named 'Cython'
ERROR: Command errored out with exit status 1: python setup.py
egg_info Check the logs for full command output.
Able to figure out below are the steps,
brew install freetds
Then try to install requirements.txt file.
If still getting errors then follow . . the below steps.
pip install cython
pip install pymssql
then again try to install requirements.txt file.

Resources