How do you install something directly from the GitHub repo? - python-3.x

I am a beginner, and tried to install PyDictionary with pip. It installed, but I had the same issue as this thread - it did not work:
How to get rid of the BeautifulSoup html parser error when I'm not using BeautifulSoup
Someone on here suggested installing if directly from the GitHub repo, but I'm not sure which file to download and what to do next.
UPDATE 1
I've updated pip, and used:
python3 -m pip install PyDictionary
(I needed python3 for some reason). I then used this program:
from PyDictionary import PyDictionary
dictionary = PyDictionary()
print (dictionary.synonym("Life"))
But got:
Warning (from warnings module): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyDictionary/utils.py", line 5 return BeautifulSoup(requests.get(url).text) UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
The code that caused this warning is on line 5 of the file /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyDictionary/utils.py.
To get rid of this warning, pass the additional argument 'features="lxml"' to the BeautifulSoup constructor. Life has no Synonyms in the API None –
UPDATE 2
python3 -m pip install git+https://github.com/geekpradd/PyDictionary
returns:
Collecting git+github.com/geekpradd/PyDictionary Cloning github.com/geekpradd/PyDictionary to /private/var/folders/sn/081bt1wd0d3gy2styt2_l1vw0000gn/T/pip-req-build-73cegdxt Running command git clone -q github.com/geekpradd/PyDictionary /private/var/folders/sn/081bt1wd0d3gy2styt2_l1vw0000gn/T/pip-req-build-73cegdxtERROR: Command errored out with exit status 1: command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/sn/081bt1wd0d3gy2styt2_l1vw0000gn/T/pip-req-build-73cegdxt/setup.py'"'"'; file__='"'"'/private/var/folders/sn/081bt1wd0d3gy2styt2_l1vw0000gn/T/pip-req-build-73cegdxt/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 /private/var/folders/sn/081bt1wd0d3gy2styt2_l1vw0000gn/T/pip-req-build-73cegdxt/pip-egg-info cwd: /private/var/folders/sn/081bt1wd0d3gy2styt2_l1vw0000gn/T/pip-req-build-73cegdxt/ Complete output (5 lines): Traceback (most recent call last):
File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/tokenize.py", line 392, in open buffer = _builtin_open(filename, 'rb') FileNotFoundError: [Errno 2] No such file or directory: '/private/var/folders/sn/081bt1wd0d3gy2styt2_l1vw0000gn/T/pip-req-build-73cegdxt/setup.py'
---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output

You can normally install directly using the github repos with
python3 -m pip install git+https://github.com/geekpradd/PyDictionary
But this repository has no setup.py file that's why it fails.
To me it's more likely a problem with conflicting python versions, so:
python3 -m pip install PyDictionary
Is enough

See VCS, from the pip docs
pip currently supports cloning over git, git+http, git+https, git+ssh, git+git and git+file:
Here are the supported forms:
git://git.example.com/MyProject#egg=MyProject
git+http://git.example.com/MyProject#egg=MyProject
git+https://git.example.com/MyProject#egg=MyProject
git+ssh://git.example.com/MyProject#egg=MyProject
git+git://git.example.com/MyProject#egg=MyProject
git+file:///home/user/projects/MyProject#egg=MyProject

Related

cannot import name '_jsonl' from partially initialized module 'jsonl'

I am trying to install the python jsonl module on an Ubuntu system. Tried on two different computers and get the same exact error:
pip install jsonl
Collecting jsonl
Downloading jsonl-1.6.tar.gz (9.0 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-5lw5f9ew/jsonl/setup.py'"'"'; __file__='"'"'/tmp/pip-install-5lw5f9ew/jsonl/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-5lw5f9ew/jsonl/pip-egg-info cwd: /tmp/pip-install-5lw5f9ew/jsonl/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-5lw5f9ew/jsonl/setup.py", line 5, in <module>
import jsonl
File "/tmp/pip-install-5lw5f9ew/jsonl/jsonl/__init__.py", line 19, in <module>
from jsonl import _jsonl as jsonl
ImportError: cannot import name '_jsonl' from partially initialized module 'jsonl' (most likely due to a circular import) (/tmp/pip-install-5lw5f9ew/jsonl/jsonl/__init__.py)
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Any ides on how to fix this? As the same exact error occurs on two systems, I'm thinking it's a config error on my part, but no idea on how to resolve. Thanks!
jsonl, the latest version 1.6 was released in 2014. I can install it with Python 2.7 but not with Python 3. The bottom line: it's an outdated abandoned project, forget it.
Another problem: it requires simplejson but doesn't declare it as a dependency.

Fresh install Python 3.9.0 or any other way to fix No module named '_ctypes' error

Since installing to Python 3.9.0, I am unable to install any libraries to my virtualenv. When trying to install libraries via pip for example I get:
$ pip3 install -r requirements.txt
Collecting anaconda==0.0.1.1
Using cached anaconda-0.0.1.1.tar.gz (726 bytes)
ERROR: Command errored out with exit status 1:
command: /home/jack/dev/37/env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-01fhtisu/anaconda/setup.py'"'"'; __file__='"'"'/tmp/pip-install-01fhtisu/anaconda/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-pip-egg-info-b71dl332
cwd: /tmp/pip-install-01fhtisu/anaconda/
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/jack/dev/37/env/lib/python3.9/site-packages/setuptools/__init__.py", line 23, in <module>
from setuptools.dist import Distribution
File "/home/jack/dev/37/env/lib/python3.9/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/home/jack/dev/37/env/lib/python3.9/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/usr/local/lib/python3.9/ctypes/__init__.py", line 8, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I have seen in a few places that this should be fixed by installing libffi-dev then reinstalling python. Here for example: Python3: ImportError: No module named '_ctypes' when using Value from module multiprocessing
What is the best way to go about doing this? I am on Ubuntu 20.04 and running python -V outside of a virtualenv reuturns Python 3.9.0.
To prevent this happening in the future is it generally recommended to only ever install newer versions on python (or any other language) in a venv and not on the system itself?
Many thanks.

pipenv problem getting MarkupSafe to automatically install as a dependency

I'm using #arocks DjangoPatternsBook and code.
I have the book and would like to follow along with the code, but I think I found a bug because it's failing for me right at the starting line on two different computers using different python environments, so I don't think it's my environment that's causing the problem.
From the book section Starting the project:
First, clone the example project from GitHub:
$ git clone https://github.com/DjangoPatternsBook/superbook2.git
Next, install pipenv system-wide [this is what I did, using brew on MacOS and using dnf on Fedora 32] or locally, but outside a virtualenv as recommended in pipenv installation documents. Alternatively, follow these commands [I did not do this]:
$ pip install -U pip
$ pip install pipenv
Now go to the project directory and install the dependencies:
$ cd superbook2
$ pipenv install --dev
This is where it fails for me with the message:
[pipenv.exceptions.InstallError]: ['Looking in indexes: https://pypi.python.org/simple', 'Collecting markupsafe==1.0', ' Using cached MarkupSafe-1.0.tar.gz (14 kB)']
[pipenv.exceptions.InstallError]: ['ERROR: Command errored out with exit status 1:', ' command: /home/alpha/.local/share/virtualenvs/superbook2-HNnQDu9M/bin/python3 -c \'import sys, setuptools, tokenize; sys.argv[0] = \'"\'"\'/tmp/pip-install-5kl59pd3/markupsafe/setup.py\'"\'"\'; __file__=\'"\'"\'/tmp/pip-install-5kl59pd3/markupsafe/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-pip-egg-info-bk6ldht4', ' cwd: /tmp/pip-install-5kl59pd3/markupsafe/', ' Complete output (5 lines):', ' Traceback (most recent call last):', ' File "<string>", line 1, in <module>', ' File "/tmp/pip-install-5kl59pd3/markupsafe/setup.py", line 6, in <module>', ' from setuptools import setup, Extension, Feature', " ImportError: cannot import name 'Feature' from 'setuptools' (/home/alpha/.local/share/virtualenvs/superbook2-HNnQDu9M/lib/python3.8/site-packages/setuptools/__init__.py)", ' ----------------------------------------', 'ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.']
ERROR: ERROR: Package installation failed...
So on a newly installed Fedora 32 machine, I did only:
$ sudo dnf install git
$ sudo dnf install pipenv
$ git clone https://github.com/DjangoPatternsBook/superbook2.git
$ cd superbook2
$ pipenv install --dev
and I think this same (or similar) sequence of commands will fail similarly in other python environments.
Does anyone have any suggestions on how to work around this problem and move forward with the code examples in the book? I've already posted a new issue in the github repo for superbook2 although I suspect the problem lies outside the superbook2 code base because I see other similar issues unrelated to superbook2.
I'll gladly post output of pipenv --support if it would help. The two python environments were using versions 3.8.3 (Fedora) and 3.8.5 (MacOS).

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.

how to import gimp in python3 script?

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

Resources