minrk / appnope Goto Github PK
View Code? Open in Web Editor NEWDisable App Nap on OS X 10.9
License: Other
Disable App Nap on OS X 10.9
License: Other
I'm getting a deprecation warning in (Windows) CI in a program depending on (macOS-based) appnope:
..\..\Users\appveyor\AppData\Local\pypoetry\Cache\virtualenvs\corrscope-2f2v7ZI7-py3.8\lib\site-packages\appnope\__init__.py:8
C:\Users\appveyor\AppData\Local\pypoetry\Cache\virtualenvs\corrscope-2f2v7ZI7-py3.8\lib\site-packages\appnope\__init__.py:8: DeprecationWarning: invalid escape sequence \d
return tuple(int(s) for s in re.findall("\d+", version_s))
In https://github.com/minrk/appnope/blob/main/appnope/__init__.py, did you mean to write r"\d+"
rather than "\d+"
?
Appnope 0.1.1 import fails. I've installed in virtual env as follows
$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ pip install -U pip
(venv) $ pip install appnope
Collecting appnope
Using cached appnope-0.1.1-py2.py3-none-any.whl (2.2 kB)
Installing collected packages: appnope
Successfully installed appnope-0.1.1
(venv) $ python
Python 3.7.7 (default, Mar 10 2020, 15:43:03)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import appnope
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'appnope'
>>>
(venv) $ pip list
Package Version
---------- -------
appnope 0.1.1
pip 20.3
setuptools 41.2.0
Are there files missing in site-packages?
(venv) $ ls -la venv/lib/python3.7/site-packages
total 8
drwxr-xr-x 3 kostas staff 96B Dec 1 14:39 __pycache__
drwxr-xr-x 9 kostas staff 288B Dec 1 14:39 appnope-0.1.1.dist-info
-rw-r--r-- 1 kostas staff 126B Dec 1 14:39 easy_install.py
drwxr-xr-x 7 kostas staff 224B Dec 1 14:39 pip
drwxr-xr-x 9 kostas staff 288B Dec 1 14:39 pip-20.3.dist-info
drwxr-xr-x 7 kostas staff 224B Dec 1 14:39 pkg_resources
drwxr-xr-x 42 kostas staff 1.3K Dec 1 14:39 setuptools
drwxr-xr-x 11 kostas staff 352B Dec 1 14:39 setuptools-41.2.0.dist-info
Since almost 2 years i figure out a problem when installing and using jupyter notebooks in a virtual environment on Mac. I always receive the following error when starting a notebook:
ModuleNotFoundError: No module named 'appnope'
I recognised that you already had the issue with appnope 0.1.1 and that going back to 0.1.0 fixed it. Unfortunately for me this problem also appears with appnope 0.1.2 and appnope 0.1.3.
I am currently using Python 3.9.15 on MacOS Venture 13.2. I also had this problem on Python 3.7 and older MacOS versions.
Steps:
from multiprocessing import Pool
import appnope
def f(x):
appnope.nope()
if __name__ == '__main__':
with Pool(5) as p:
print(p.map(f, [1]))
ipython crash.py
objc[2560]: +[NSString initialize] may have been in progress in another thread when fork() was called.
objc[2560]: +[NSString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
It would be great if this could also be used to prevent system sleep. All the required infrastructure already seems to be there.
At least the _nope module works on Python 3 and probably the rest too. But setup.py uses exec
which is a function in py3k.
Thanks for this BTW: we've got IEP running on Maverick again :)
Seen in ipython/ipykernel#902
../../miniconda/envs/ipykernel_env/lib/python3.8/site-packages/appnope/__init__.py:7: in <module>
if sys.platform != "darwin" or V(platform.mac_ver()[0]) < V("10.9"):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <[AttributeError("'LooseVersion' object has no attribute 'vstring'") raised in repr()] LooseVersion object at 0x7faea458e7c0>
vstring = '10.16'
def __init__ (self, vstring=None):
> warnings.warn(
"distutils Version classes are deprecated. "
"Use packaging.version instead.",
DeprecationWarning,
stacklevel=2,
)
E DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
../../miniconda/envs/ipykernel_env/lib/python3.8/site-packages/setuptools/_distutils/version.py:53: DeprecationWarning
[I 20:36:06.448 LabApp] KernelRestarter: restarting kernel (4/5), new random ports
Traceback (most recent call last):
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/ipykernel_launcher.py", line 16, in
app.launch_new_instance()
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/traitlets/config/application.py", line 844, in launch_instance
app.initialize(argv)
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/traitlets/config/application.py", line 87, in inner
return method(app, *args, **kwargs)
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/ipykernel/kernelapp.py", line 582, in initialize
self.init_kernel()
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/ipykernel/kernelapp.py", line 452, in init_kernel
user_ns=self.user_ns,
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/traitlets/config/configurable.py", line 537, in instance
inst = cls(*args, **kwargs)
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/ipykernel/ipkernel.py", line 86, in init
appnope.nope()
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/appnope/_nope.py", line 90, in nope
"Because Reasons"
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/appnope/_nope.py", line 60, in beginActivityWithOptions
NSProcessInfo = C('NSProcessInfo')
File "/Users/brandon/miniconda3/envs/ancestry/lib/python3.7/site-packages/appnope/_nope.py", line 38, in C
assert ret is not None, "Couldn't find Class %s" % classname
AssertionError: Couldn't find Class NSProcessInfo
jupyter --version
jupyter core : 4.7.0
jupyter-notebook : 6.1.5
qtconsole : not installed
ipython : 5.8.0
ipykernel : 5.3.4
jupyter client : 6.1.7
jupyter lab : 2.2.9
nbconvert : 6.0.7
ipywidgets : not installed
nbformat : 5.0.8
traitlets : 5.0.5
Hi!
Could you check the issue please?
(I just found the appnode repository e.g here.)
I recently encountered the IPython AppNap issue probably after upgrading my Mac from Mojave to Catalina. I observe very slow key response (freezes every ~1 sec) in an IPython session after using the ROOT package, which is a huge analysis library for particle physics. The issue was reported here a few days ago because I first thought that it was a ROOT issue.
https://sft.its.cern.ch/jira/browse/ROOT-10860
After discussing the ROOT developers, it was found that my issue was due to AppNap, and calling appnope.nope()
in ~/.ipython/profile_default/startup/ipython_init.py
resolved it. So, please first let me thank you very much.
What still puzzling me is that this issue does not appear universally. Would you tell me why I need to manually call appnope.nope()
in the environments 1 and 2 ? Do you have any idea? If there is a reason, I would like to make a issue report in the Homebrew repo.
I think you forgot to add this file...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.