Unable to start python on mac - python

I have been working with python on my laptop and noticed that since this morning python does not execute any scripts anymore. With little debugging I realized that python does not even start its prompt on my workspace. I am using python 2.7 below:
Pranav-Mac:[~]$ python
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 548, in <module>
main()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 527, in main
known_paths = removeduppaths()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 110, in removeduppaths
dir, dircase = makepath(dir)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py", line 80, in makepath
dir = os.path.join(*paths)
AttributeError: 'module' object has no attribute 'path'
Pranav-Mac:[~]$ echo $PYTHONPATH
/Users/pranav/mylib
Pranav-Mac:[~]$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/mysql/bin
Pranav-Mac:[~]
So I tried reinstalling python 2.7.11 which did not fix the issue.
Any clue what could have gone wrong here ?

Deleted all old *.pyc files from my mac to fix this issue.

Related

How can I solve Python IDLE3 start problem?

friends...
I've just installed IDLE3 package for Python (running Python 3.8)...
When I try to start it there is a message like this:
[ibmsys01#gustavo-ubuntu ~/zPDT]$ idle
** Invalid host: ('192.168.0.17', 57676)
Traceback (most recent call last):
File "/usr/bin/idle", line 5, in <module>
main()
File "/usr/lib/python3.8/idlelib/pyshell.py", line 1516, in main
shell = flist.open_shell()
File "/usr/lib/python3.8/idlelib/pyshell.py", line 331, in open_shell
if not self.pyshell.begin():
File "/usr/lib/python3.8/idlelib/pyshell.py", line 1049, in begin
client = self.interp.start_subprocess()
File "/usr/lib/python3.8/idlelib/pyshell.py", line 465, in start_subprocess
self.rpcclt.accept()
File "/usr/lib/python3.8/idlelib/rpc.py", line 544, in accept
raise OSError
OSError
[ibmsys01#gustavo-ubuntu ~/zPDT]$
I haven't found any reference to this error. Has any of you seen it before? Can you please help get through it?
My environment is:
Linux Ubuntu 20.04 LTS
Python 3.8.5
IDLE3
An additional detail: invoking "idle" or "idle3" gives me the same error.
Can you please help me get through this?
Thank you and best regards.
Gustavo.

Py2App>0.13 always outputs ValueError/ Py2App v0.13 App not opening on second machine

So I finally got my python program working on my Mac (Catalina 10.15.4), but I am greeted with the following error when it is opened on another Mac (High Sierra 10.13.6.)
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 355, in <module>
_run()
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 340, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/dist/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 9, in <module>
from pysine import sine
File "pysine/__init__.pyc", line 14, in <module>
File "pysine/pysine.pyc", line 1, in <module>
File "pyaudio.pyc", line 116, in <module>
ImportError: dlopen(/Volumes/dist/Riff Gen.app/Contents/Resources/lib/python3.6/lib-dynload/_portaudio.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
in /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib
A simple tkinter test with various sounds and images works fine on the second machine, but not this script. I've tried adding all the packages manually, tried --nostrip, manually including 'libportaudio.2.dylib', and dozens of other ideas from countless outdated forums to no avail.
When the play function of my application is stripped, the app opens and crashes shortly thereafter - giving me the following error:
Traceback (most recent call last):
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 81, in <module>
_run()
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 66, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 2037, in <module>
root.mainloop()
File "tkinter/__init__.pyc", line 1277, in mainloop
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Fatal Python error: PyEval_RestoreThread: NULL tstate
Current thread 0x00007fffa118e380 (most recent call first):
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...none found.
[Process completed]
I have been using Python 3.6 and Py2App v0.13 because it is, unfortunately, the only version that has successfully packaged my program in a standalone package. Any version later than 0.13 gives me the following error even when bundling in alias mode:
Traceback (most recent call last):
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 420, in <module>
_run()
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 414, in _run
exec(compile(source, script, 'exec'), globals(), globals())
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/riffgen_v1.01.py", line 7, in <module>
from tkinter import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ValueError: character U+6573552f is not in range [U+0000; U+10ffff]
I've seen a handful of people with similar errors to the one above, but the few solutions I've seen had no success.
I'm assuming there is a simple solution to both of these errors, but after a long two weeks of tinkering, I'm out of ideas. I just began programming and really want to continue to deploy GUI programs, so I am desperate to get this functional. Any help is greatly appreciated!!
Probably not an answer you were hoping for, but this might give you some ideas where to look:
check if you don't have multiple pythons installed. Make sure you run it with 3.6. (but you probably already did)
Check the modules installed on both PC's help('modules') in a python shell.
Check if the correct version of the modules is installed. Install the exact same versions pip install SomePackage==1.0.4
Symbol not found: ____chkstk_darwin seems to be a very mac related issue. I'd start searching there in combination with the modules you use in your script. This is the only post I found on stackoverflow and it suggests looking at the PATH settings; plaidml-setup uses the wrong lib path and gets OSErrors

No Python IDE will start and it will not start in the Command Prompt

When I click on my Python IDE's (IDEL, PyScripter) they will not even open. I tried typing python in the command prompt and this is what happened:
C:\>python
Traceback (most recent call last):
File "C:\Python27\ArcGIS10.5\lib\site.py", line 548, in <module>
main()
File "C:\Python27\ArcGIS10.5\lib\site.py", line 537, in main
aliasmbcs()
File "C:\Python27\ArcGIS10.5\lib\site.py", line 469, in aliasmbcs
codecs.lookup(enc)
File "C:\Python27\ArcGIS10.5\lib\encodings\__init__.py", line 85, in search_function
norm_encoding = normalize_encoding(encoding)
File "C:\Python27\ArcGIS10.5\lib\encodings\__init__.py", line 57, in normalize_encoding`enter code here`
encoding = str(encoding, "ascii")
TypeError: str() takes at most 1 argument (2 given)
Did you recently install ArcGIS? It looks to me like ArcGIS installed a few libraries, and overwrote your site.py, but it's using code that's meant for Python3 rather than Python2.7. The str function is capable of taking in 2 arguments in Python3 but not in Python2.
To get your Python to work again, you could try deleting the entire ArcGIS10.5 directory from your computer (or temporarily moving it to your desktop and seeing if that helps). You can also try running python -S in Command Prompt to run Python without importing site.py.
To try to get ArcGIS working, you might be able to install Python3, and reinstall ArcGIS using that.
Hopefully that helps!

Python 3.3.5 Console does not start in PyCharm 2016.3.1

Please, could you help? I am unable to get the python console started in PyCharm. Have played with all option available and have trawled through the documentation, but cannot figure this one out. Any help would be appreciated. Please find below the error I get in the console...
OS: Win 10
C:\Miniconda3\python.exe "C:\Program Files (x86)\JetBrains\PyCharm\helpers\pydev\pydevconsole.py" 64331 64332
Traceback (most recent call last):
File "C:\Miniconda3\lib\site-packages\traitlets\traitlets.py", line 526, in get
value = obj._trait_values[self.name]
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm\helpers\pydev\pydevconsole.py", line 526, in <module>
pydevconsole.start_server(pydev_localhost.get_localhost(), int(port), int(client_port))
File "C:\Program Files (x86)\JetBrains\PyCharm\helpers\pydev\pydevconsole.py", line 355, in start_server
interpreter = InterpreterInterface(host, client_port, threading.currentThread())
File "C:\Program Files (x86)\JetBrains\PyCharm\helpers\pydev\_pydev_bundle\pydev_ipython_console.py", line 25, in __init__
self.interpreter = get_pydev_frontend(host, client_port, show_banner=show_banner)
File "C:\Program Files (x86)\JetBrains\PyCharm\helpers\pydev\_pydev_bundle\pydev_ipython_console_011.py", line 488, in get_pydev_frontend
_PyDevFrontEndContainer._instance = _PyDevFrontEnd(show_banner=show_banner)
File "C:\Program Files (x86)\JetBrains\PyCharm\helpers\pydev\_pydev_bundle\pydev_ipython_console_011.py", line 318, in __init__
self.ipython = PyDevTerminalInteractiveShell.instance()
File "C:\Miniconda3\lib\site-packages\IPython\config\configurable.py", line 337, in instance
inst = cls(*args, **kwargs)
File "C:\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 512, in __init__
self.init_readline()
File "C:\Miniconda3\lib\site-packages\IPython\core\interactiveshell.py", line 1911, in init_readline
if self.readline_use:
File "C:\Miniconda3\lib\site-packages\traitlets\traitlets.py", line 554, in __get__
return self.get(obj, cls)
File "C:\Miniconda3\lib\site-packages\traitlets\traitlets.py", line 532, in get
% (self.name, obj))
traitlets.traitlets.TraitError: No default value found for None trait of <_pydev_bundle.pydev_ipython_console_011.PyDevTerminalInteractiveShell object at 0x00000000042CFBA8>
Process finished with exit code 1
Ok, after much twiddling about:
Changing the interpreter to a different version (to Python 3.5.x) made this work. This made me wonder if IPython was the issue.. and it sure was!!
The problem is that the IPython for Python 3.3.5 does not work with PyCharm. IPython Version 5 was installed by PyCharm, but does not work with Python 3.3.5.
I removed IPython using 'Conda uninstall' and then 'Conda clean' and restarted the console, it then worked like a charm...
In essence:
1. Exit Pycharm
2. Remove IPython - use 'Conda remove/uninstall' and then 'conda clean' to completely get rid of it.
3. Restart Pycharm and allow it reimport all 'skeletons'
4. Restart Console.
I had a similar problem on Fedora 24. For some reason Fedora still ships IPython 3.x :/ I simply upgraded it with pip3 install ipython --upgrade which installed IPython 6.0.0 and it works :D

Ipython installation on 3.3 x64 errors

I don't have experience in downloading libraries, so any help is appreciated. I've got a fresh install of Python3.3 and am trying to get IPython for 64bit Windows 7. The IPython .exe installer ran fine and completed normally, but I can't access the program. I looked through their documentation, and tried the commands there, but
$ python setup.py install
returns invalid syntax, highlighting "setup". I thought the fix might be in the distribute library mentioned on the page, so I went to go try and get that first. However, using the script from distribute's install page revealed it's own errors, namely
Traceback (most recent call last):
File "C:\Python33\distribute_setup.py", line 541, in <module>
sys.exit(main())
File "C:\Python33\distribute_setup.py", line 537, in main
tarball = download_setuptools(download_base=options.download_base)
File "C:\Python33\distribute_setup.py", line 200, in download_setuptools
log.warn("Downloading %s", url)
File "C:\Python33\lib\distutils\log.py", line 47, in warn
self._log(WARN, msg, args)
File "C:\Python33\lib\distutils\log.py", line 30, in _log
if stream.errors == 'strict':
AttributeError: errors
I've been at it for a couple hours now, and I'm fresh out of ideas. What next?
It looks like you ran into Python bug 12967. You need to run distribute_setup.py outside of IDLE (i.e. in a command prompt).

Categories