Edited for posterity: I got it to work. In my case, I had to use the --user option in pip. pip uninstalled pympress and then
python3 -m pip install --user pympress
OP continues below:
I'm trying to install Pympress, a LaTeX Beamer slideshow viewer on MacOS High Sierra. I've been wrestling with this install for a couple days now with various issues. I think I'm getting close, with everything finally settled on my Python 3.7 build. However, I'm hung up on the Gtk dependency.
Having installed all the dependencies (as far as I can tell, including things that I think aren't well-described on that Github page), I go to run the program with
pympress my_slides.pdf
and get the ValueError in the traceback below:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pympress", line 7, in <module>
from pympress.__main__ import main
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-
packages/pympress/__main__.py", line 41, in <module>
from pympress import util
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pympress/util.py", line 36, in <module>
gi.require_version('Gtk', '3.0')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gi/__init__.py", line 129, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available
It just doesn't seem to have installed the gtk3 namespace in the proper place (and I don't know where it is at the moment, if at all), and I'm at a loss as to how to do so manually, if possible. The closest I've heard is installing gir1.2-gtk-3.0, but as far as I can tell that's a Linux need only, and neither brew or pip find it (same issue as this post).
Following the minimum working program on the PyGObject site site (another low-level dependency), I have the same namespace error. I've installed using their instructions as well, written their hello.py file and it doesn't run, with the same issue.
Have I missed a dependency somewhere? I've both followed the Pympress dependency install directions to the letter, as well as restarting and installing everything various ways independently using brew, which itself doesn't show any broken links.
Edit: it seems that manually compiling gtk and its dependencies, not going through brew, solved this namespace problem. That said, the package is also dependent on Poppler, which is now giving me the same error, just farther along in the code. Manually compiling this time hasn't seemed to work. I'll leave this up for posterity (and in case anyone has thoughts), but my current "workaround" is just going to be booting into Windows for the program, as binary installers are available.
Related
Example: I was trying to update my system today and I got this error:
wli#ubuntu:~$ update-manager
Traceback (most recent call last):
File "/usr/bin/update-manager", line 28, in <module>
from gi.repository import Gtk
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 36, in <module>
from ._gi import _gobject
ModuleNotFoundError: No module named 'gi._gi'
Not sure what to do? Ive tried every common fix found in forums online, reinstalling and uninstalling python, everything. The only thing I can think of that may have caused this is that I tried to change my system's python version through a series of convoluted commands in order to force Atom to use python3. Any ideas for how I can fix this? I'd really like to be able to install things on my laptop; I can't even reinstall Ubuntu because that requires actually being able to use Python.
I even made my system point to 2.7.6 using update-alternatives but it still doesn't work.
For reference, the system Python version is now 2.7.6 and I run 14.04.
I had to uninstall and reinstall python for other reasons.
Right now I downloaded python 3.8.2 through pyenv but running:
import tkinter
The error I get is:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cagava/.pyenv/versions/3.8.2/lib/python3.8/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
why is that so? Am I missing some modules in python installation?
Note that I am working on a Mac
I've tried the solution proposed on the issue (Python not configured for Tk) and others suggesting the same method but it didn't solve my problem
Struggling with this myself. For all the talk about the "annual ritual" to include tkinter with Python, it sure isn't well integrated, especially when using pyenv.
I'm about to take the plunge one site suggested: removing pyenv completely, then installing tcl-tk, then compiling a number of post-tcl-tk dependencies that come up after the tcl-tk install, then reinstalling pyenv (which should, supposedly, then add tkinter support - even though tkinter was installed on the default system python of 2.7.16, then reinstalling the versions of Python I've already installed (3.7 and 3.8 and which seem to work for everything but tkinter). Like I said - not well integrated. Were it not for the many comments about how well tkinter has been expanded and maintained I'd be tempted to (and actually, was tempted to) try something else.
Linux Ubuntu and PopOS (Ubuntu derivative) both display the same problem, on two different machines. I'll give the above a try and report back on the fireworks.
From IDLE, I tried to run a script with a newly installed scrapy 1.0.3.
I'm using a script from a friend whom it worked for (but on Windows, I'm on a Mac).
From the import of scrapy on the first line, I get this error when running the program:
ImportError: No module named twisted.persisted.styles
The whole script, if it's helpful, points to this:
Traceback (most recent call last):
File "/Users/eliasfong/tutorial/tutorial/spiders/medspider.py", line 1, in <module>
import scrapy
File "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 27, in <module>
from . import _monkeypatches
File "/Library/Python/2.7/site-packages/scrapy/_monkeypatches.py", line 20, in <module>
import twisted.persisted.styles # NOQA
ImportError: No module named twisted.persisted.styles
Any suggestions on how to tackle this problem?
Just try to force the update of twisted :
pip install twisted --upgrade
That works for me with python3.4 and Scrapy==1.1.0rc1
Either twisted is installed on your mac (I highly doubt it since it's not a standard library) and for whatever reason the IDE (i'm assuming that's what you mean since you typed "idle") or the terminal you are in doesn't have your updated environment variables, meaning it doesn't understand where your default python libraries are (again I highly doubt it), or you simple do not have twisted installed on your mac. If it's not installed you have a couple of options:
The easiest way to install a python package is through pip.
If that not an option you can try homebrew which is another package manager for macs. It offers an easy way to install packages correctly.
If that still is not an option for you or you simply don't want to attempt that you can download twisted directly from here (the .bz2 since you're on a mac), click on it and it should unzip it for you. Then just run setup.py and it should install it in the correct location on your mac.
If that still doesn't work and you have decent knowledge of unix. Use the "locate" command on the terminal and find out where your dist-packages directory is and put the source for twisted in there directly and then attempt to import twisted in your IDE or in the python interpreter to verify that it is installed.
note: If you're still having problems after it is installed trying restarting your IDE or messing with some setting to make sure your IDE has the right environment and python path. Hope that helps!
It could be related to having installed Python without bzip2. I had the same error and this helped me, see the accepted answer here:
Installing Twisted through pip broken on one server
Had this exact thing on FreeBSD. Solution (as root/sudo):
chmod -R go+rX /usr/local/lib/python2.7/site-packages
Some directory permissions weren't set up right on install.
I'm installing a Python (2.7.8) environment locally in my home folder on a server, in order to use newer versions of Python and some of its libraries (Numpy, Theano) together with OpenBLAS. For this, I first installed Python in the folder usr in my home directory (/home/my_home/usr/) as described here:
https://mail.python.org/pipermail/tutor/2002-March/012903.html
The installation seems to have gone smoothly. I checked this by starting the Python interpreter, which displays the right version on startup.
Following this, I installed OpenBLAS into /home/my_home/opt folder as described here:
Compiling numpy with OpenBLAS integration
... which also didn't give me any errors. However, now when I try installing Numpy (according to the instructions in the above link), I get the following error:
Traceback (most recent call last):
File "setup.py", line 22, in <module>
import subprocess
File "/home/ext_sxc/usr/lib/python2.7/subprocess.py", line 427, in <module>
import select
ImportError: No module named select
I suppose the straightforward thing to do is to find the package for select, compile and install it. I'm not sure if this is the right thing to do because the last time I installed Python 2.7.6 locally in a home directory, there were no such errors. As I understand, the select module should have been installed along with Python.
This also happens when I try installing IPython in a similar way in my home folder. The library which gives the ImportError is different.
I'm wondering if these are related to a more general mistake I may have made while installing Python. I'd appreciate any advice on this issue. Please let me know if any additional information would help. Thanks!
I'm trying to build an application using the new-ish Pyramid framework. I'm new to Pyramid and have no idea what Zope does (the importance of which will become apparent). I followed the basic tutorial, but when I try to run the application I get this traceback:
Traceback (most recent call last):
File "tasks.py", line 4, in <module>
from pyramid.config import Configurator
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyramid-1.2-py2.6.egg/pyramid/__init__.py", line 1, in <module>
from pyramid.request import Request
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/pyramid-1.2-py2.6.egg/pyramid/request.py", line 1, in <module>
from zope.deprecation import deprecate
ImportError: No module named deprecation
I tried install Pyramid using setuptools:
sudo easy_install pyramid
Which, among a lot of other output included this:
Searching for zope.deprecation
Reading http://pypi.python.org/simple/zope.deprecation/
Best match: zope.deprecation 3.5.0
Downloading http://pypi.python.org/packages/source/z/zope.deprecation/zope.deprecation-3.5.0.tar.gz#md5=1e7db82583013127aab3e7e790b1f2b6
Processing zope.deprecation-3.5.0.tar.gz
Running zope.deprecation-3.5.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ZiLy8j/zope.deprecation-3.5.0/egg-dist-tmp-yGFSor
Adding zope.deprecation 3.5.0 to easy-install.pth file
Which I thought should cover it.
I also tried installing zope via macports:
sudo port install zope
sudo port install py26-zopeinterface
I've also tried to run sudo port load zope before running the script, but no help there.
I also tried downloading the source from http://pypi.python.org/pypi/zope.interface and building it manually in directory.
Any ideas what I'm doing wrong?
----EDIT----
One guess is that setuptools in installing its zope components into my system's default Python framework (which is an Enthought distribution), but my default python environment is the one that Macports installed, so perhaps the Macports zope module has some but not all of the components, such as zope.deprecate.
The documentation includes information about how to use a virtualenv to install Pyramid. It's very, very recommended to use a virtualenv this way. System packages already installed in your main Python will have weird interactions with Pyramid's requirements.
You may get an answer from someone more familiar with Pyramid, but the problem here is that pyramid.request depends on zope.deprecation and it isn't installed/available. You'll have to elaborate much more on "I've tried installing zope using ..." for me to help you more.
Be sure you're running pyramid from the same python that you did the installation to. If that's the case then the zope.deprecation package should be installed there. What do you get from python -c "import zope.deprecation ; print import zope.deprecation"?
I solved it by installing zope.deprecation OS package:
sudo apt-get install zope.deprecation
Just re-install pyramid to fix.
I have had problem with moving class into sub-module.
The problem was another component of software was importing class from "OLD" module. And also there was cycling problem with inheritance.
So the solution was to use zope.deferredimport. The code looks like this:
import warnings
import zope.deferredimport
warnings.simplefilter("default")
zope.deferredimport.initialize()
zope.deferredimport.deprecated(
"Import from openprocurement.contracting.core.tests.base instead",
BaseContractWebTest='openprocurement.contracting.core.tests.base:BaseContractWebTest',
)
So now, when any component of software, that uses import from "OLD"
module doesn't get ImportError. Class is imported from "NEW" module. And warning is displayed like this:
DeprecationWarning: BaseContractWebTest is deprecated. Import from openprocurement.contracting.core.tests.base instead
So this is it. The main part zope.deferred took care of cycle imports. That saved my life.