installing PyGObject via pip in virtualenv [duplicate] - python

This question already has answers here:
Python cannot install PyGObject
(4 answers)
Closed 6 years ago.
I'm actually upgrading an old django app from python2.7 to python3.4. While installing pygobject via pip, I got this error:
Collecting pygobject
Using cached pygobject-2.28.3.tar.bz2
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-9dp0wn96/pygobject/setup.py", line 272
raise SystemExit, 'ERROR: Nothing to do, gio could not be found and is essential.'
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9dp0wn96/pygobject
I am trying to install it in a virtualenv. System-wide installation doesn't work either... I am working on arch linux with python3.4
I have installed the arch package named pygobject-devel 3.16.2-1 but I still can't import gobject python module
What is this damned missing gio?
Any help is welcomed...
Thanx in advance !

ANSWER IS NOW IN THE POST TAGGED IN COMMENT ABOVE !!!!
Have a look there => Python cannot install PyGObject
Ok I just managed it !
To install PyGObject in virtrualenv, give up with pip.
Install PyGObject system-wide (with your package manager or compile it manually). For example, in my case :
sudo pacman -Suy python-gobject2
Link it in your virtualenv :
ln -s /usr/lib/python3.4/site-packages/gobject* /WHEREVER/IS/YOUR/VIRTUALENV/venv/lib/python3.4/site-packages/
You might need to link some other modules (in my case glib) :
ln -s /usr/lib/python3.4/site-packages/glib* /WHEREVER/IS/YOUR/VIRTUALENV/venv/lib/python3.4/site-packages/
You might find some helpful infos about system-wide and virtualenv installations and interactions between modules here :
virtualenv: Specifing which packages to use system-wide vs local

Related

PyQt5 dependency in a module on Debian [duplicate]

This question already has answers here:
Install PyQt5 5.14.1 on Linux
(8 answers)
Closed 3 years ago.
I have a Python module with a __main__ that uses PyQt5. I've installed PyQt5 on a Debian Buster box:
apt-get install python3-pyqt5
The __main__ program runs as expected if I execute
python3 mymodule/__main__.py
from the source directory. Now I've installed the module into python:
python3 setup.py install
That worked. The setup.py lists a dependency on pyqt5:
setup(
# ...
install_requires=['PyQt5'],
entry_points={"gui_scripts": ["mymodule = mymodule.__main__:main"]},
Setup created a script /usr/local/bin/mymodule. When I run that, I get an error message:
pkg_resources.DistributionNotFound: The 'PyQt5' distribution was not found and is required by mymodule
What am I missing?
EDIT: tried installing pyqt5 via pip, got the following error:
seva#sandbox:~$ sudo pip3 install pyqt5
Collecting pyqt5
Using cached https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
Installing build dependencies ... done
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.7/tokenize.py", line 447, in open
buffer = _builtin_open(filename, 'rb')
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-26kj5hrc/pyqt5/setup.py'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-26kj5hrc/pyqt5/
OS-level package managers are designed to be consistent within itself. But they aren't designed to interoperate with language package managers. apt-get-installed python3-pyqt5 could be recognized by other Debian packages but not by pip/setuptools.
So either you convert your package to .deb (using stdeb, for example), set dependency to python3-pyqt5 and install it with apt/apt-get/dpkg. Or you install everything using pip:
pip install pyqt5
pip install . # to install your package
If your dependencies are properly declared in the package the latter command should be enough — pip will run the former itself.
PS. Also please consider virtualenv to separate pip-installed packages from system-installed. virtualenv itself could be system-installed or user-installed:
apt install python3-virtualenv
or
pip install [--user] virtualenv

Failed to install wsgiref on Python 3

I have a problem installing wsgiref:
$ python --version
Python 3.6.0 :: Anaconda 4.3.1 (x86_64)
$ pip --version
pip 9.0.1 from /anaconda/lib/python3.6/site-packages (python 3.6)
My requirement.txt file are shown as below.
numpy==1.8.1
scipy==0.14.0
pyzmq==14.3.1
pandas==0.14.0
Jinja2==2.7.3
MarkupSafe==0.23
backports.ssl-match-hostname==3.4.0.2
gnureadline==6.3.3
ipython==2.1.0
matplotlib==1.3.1
nose==1.3.3
openpyxl==1.8.6
patsy==0.2.1
pyparsing==2.0.2
python-dateutil==2.2
pytz==2014.4
scikit-learn==0.14.1
six==1.7.3
tornado==3.2.2
wsgiref==0.1.2
statsmodels==0.5.0
when I run pip install -r requirement.txt, I got this error
Collecting wsgiref==0.1.2 (from -r requirements.txt (line 20))
Using cached wsgiref-0.1.2.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/xs/y0pbzxkn7gqcdtrz4cpxtwrw0000gn/T/pip-build-hkiqbu1j/wsgiref/setup.py", line 5, in <module>
import ez_setup
File "/private/var/folders/xs/y0pbzxkn7gqcdtrz4cpxtwrw0000gn/T/pip-build-hkiqbu1j/wsgiref/ez_setup/__init__.py", line 170
print "Setuptools version",version,"or greater has been installed."
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/xs/y0pbzxkn7gqcdtrz4cpxtwrw0000gn/T/pip-build-hkiqbu1j/wsgiref/
I have tried to run pip install --upgrade setuptools and sudo easy_install -U setuptools but neither works. How can I solve this problem?
wsgiref is already been included as a standard library in Python 3...
So in case if you are trying with Python 3 just go ahead and import wsgiref thats it.
According to this line SyntaxError: Missing parentheses in call to 'print', I think it needs Python 2.x to run the setup.py. Whether to use parentheses in print is the different syntax of Python 2 and Python 3.
This is the solution from the Github issue:
There are a few fixes that will get you running, in order of least work to most:
Switch over to python2.7 for your will installs.
Try to upgrade wsgiref with pip install --upgrade wsgiref, and see if the latest version works with your setup, and with will (if it doesn't, you'd notice the http/webhooks stuff not working.
If you try 2) and it works, submit a PR here with the upgraded version in requirements.txt. (You can find out what versions you've got by using pip freeze).
You can find more about the syntax difference here
Solution:
Flask-restful is deprecated, use version flask-restx

egg_info error when installing python modules

I am new to Python and I am trying to install pypgen.
As explained one the webpage, I first installed "samtools" (via brew install samtools as recommended).
Trying to install pypgen
I tried the 4 ways suggested by the author to install pypgen
$pip3.6 install pypgen
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/yv/n6rkh3sn5mn5qpsn87lvjw4m0000gp/T/pip-build-aQiBgg/pypgen/
$easy_install pypgen
Processing pypgen
error: Couldn't find a setup script in /Users/remi/Downloads/pypgen-0.2.1/pypgen
$pip3.6 install -e git+https://github.com/ngcrawford/pypgen.git
Could not detect requirement name, please specify one with #egg=
I downloaded "pypgen-0.2.1.tar.gz" from the pypgen website, uncompressed it, cd to the folder and did
$python setup.py install
Traceback (most recent call last):
File "setup.py", line 1, in <module>
import distribute_setup
ImportError: No module named distribute_setup
So, I did
$pip3.6 install distribute
but it did not solve the previous issue
Trying to Solve egg_info error
This egg_info error seems to be key. I tried to download this file and did
sudo python ez_setup.py
as recommended on this post but it did not solve the error messages above. I then tried
sudo pip3.6 install --upgrade setuptools
as recommended on this post but I keep receiving the same error messages when doing pip3.6 install pypgen
I am using Python 3.6 but I also have the version 2.7 installed. I tried everything with both versions (pip3.6 and pip2.7) and get the same errors. I am on MAC OS X 10.11.3

Syntax error when installing csc-pysparse

I am new to Python and I am trying to install recsys package.
http://ocelma.net/software/python-recsys/build/html/installation.html
For this i need to install some pre-requiste packages, so i have to run this using pip
pip install csc-pysparse networkx divisi2
But whenever i run this i get the following in logs
Collecting csc-pysparse
Using cached csc-pysparse-1.1.1.4.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\64\AppData\Local\Temp\pip-build-wn7_65_9\csc-pysparse\
setup.py", line 33
print 'setuptools module not found.'
^
SyntaxError: Missing parentheses in call to 'print'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\i054564\
AppData\Local\Temp\pip-build-wn7_65_9\csc-pysparse\
I checked that setuptools exist in my python installation here
C:\Python34\lib\site-packages
I have ran everything from unstinalling setuptools to install it again, upgrade command, but it does not work.
Not able to figure out why setuptools is not found. Is it not found in the path of where pip resolves it from ?
cheers,
Saurav
The code triggering the error is Python 2-specific and is illegal in Python 3.
Apparently, csc-pysparse doesn't support Python 3 (its README only mentions 2.6) and looks abandoned (6 years since last commit).
Some guys out there suggest replacing it with SciPy.
The error is coming from the installation code of recsys package. In order to avoid this error, you need to install setuptools separately.
For debian machines, the below command will work.
sudo apt-get install python3-setuptools
For other machines, please checkout installation instructions at the link
Once setuptools package is installed, you can proceed with csc-pysparse installation.

Oursql insallation failing wtih "cython not found"

Trying to install oursql driver for python3x and sqlalchemy0.8 on ubuntu 12.10. It fails with the following error.
sudo pip-3.2 install oursql
Downloading/unpacking oursql
Running setup.py egg_info for package oursql
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build/oursql/setup.py", line 53
print "cython not found, using previously-cython'd .c file."
^
SyntaxError: invalid syntax
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build/oursql/setup.py", line 53
print "cython not found, using previously-cython'd .c file."
^
SyntaxError: invalid syntax
When I try to install cython I seem to already have it:
sudo pip-3.2 install cython
Requirement already satisfied (use --upgrade to upgrade): cython in /usr/local/lib/python3.2/dist-packages
Cleaning up.
What can I do to make it run?
Had the same error when running pip-3.2.
This is how I made it work:
Created my env using python-3.2:
virtualenv -p /usr/bin/python3.2
Installed the required packages:
sudo apt-get install python-dev
sudo apt-get install libmysqlclient-dev
Then installed:
sudo pip install cython
sudo pip install oursql
Edit1:
I was able to get pass you error with my above recomendations, but i was wrong (python3.2 was unable to read oursql). I tried the following and was able to make a connection:
First:
sudo apt-get install python3.2-dev
Then installed oursql for Python 3 from source (as suggested by it's maintainer here):
Get the Python 3 version of oursql from here and compile it from source (Don't have enough reputation to post the link, just go to oursql official site for installation instructions).
The maintainers have two packages, one for python 2.x and one for python 3.x, you should run:
pip install oursql3
There is nothing about cython.
You just encoutered a syntax error in print, because the print statement doesn't use brackets there. They were optional in Python 2's print statement, but are required in Python 3's print() function.
install it manually - reqs: python-dev, cython
then download oursql package (try 0.9.3.zip)
and
python setup.py install

Categories