A few weeks ago I had brew update various casks and now I can't run s3cmd. I get the following errors:
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/usr/local/Cellar/s3cmd/2.0.2_3/libexec/bin/../lib/python3.8/site.py", line 703, in <module>
main()
File "/usr/local/Cellar/s3cmd/2.0.2_3/libexec/bin/../lib/python3.8/site.py", line 694, in main
execsitecustomize()
File "/usr/local/Cellar/s3cmd/2.0.2_3/libexec/bin/../lib/python3.8/site.py", line 548, in execsitecustomize
import sitecustomize
File "/usr/local/lib/python2.7/site-packages/sitecustomize.py", line 4, in <module>
import re
File "/usr/local/Cellar/s3cmd/2.0.2_3/libexec/lib/python3.8/re.py", line 143, in <module>
class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'
Based on the errors, I assumed this is python 3 issue. The Mac comes with python 2.7 and I use a lot of 2.7 python scripts so I don't want to make a system wide change.
Based on some research, it doesn't seem that s3cmd requires python3.
I could be very wrong about it needing python3 and it's some other issue. The rest of my python code runs just fine so it's not a fundamental issues with python and seems to only be s3cmd.
Everything in brew seems to be up to date and I've uninstalled and installed s3cmd miltiple times trying to fix this.
I am running OS X 10.14.6
Did you try that?
Why Python 3.6.1 throws AttributeError: module 'enum' has no attribute 'IntFlag'?
the two top answers were to:
pip uninstall -y enum34
OR
unset PYTHONPATH
Related
I'm using the latest version of Mephisto on macOS Catalina. I am trying to run ParlAI, and specifically the acute_eval task.
According to the Instructions of both Mephisto and AcuteEVAL, I should be able to execute run.py and get the task running. However, I get this error as I run it, using this command:
python run.py --pairings_filepath=example/pairings.jsonl
And this is the error:
Traceback (most recent call last):
File "run.py", line 17, in <module>
from parlai.crowdsourcing.tasks.acute_eval.acute_eval_blueprint import BLUEPRINT_TYPE
File "/Users/moli/opt/anaconda3/envs/py36/lib/python3.6/site-packages/parlai/crowdsourcing/tasks/acute_eval/acute_eval_blueprint.py", line 12, in <module>
from mephisto.core.registry import register_mephisto_abstraction
ModuleNotFoundError: No module named 'mephisto.core'
The ParlAI installation instructions on github state that Python 3.7 or higher is required, however it appears that you are using Python 3.6. This is likely the cause of the issue, and the program should work if you upgrade your Python version.
I've already installed this package (SpeechRecognition) on my laptop, now I'm trying to make it work on my Imac (sierra aswell).
I followed the installation the same as on the macbook.
But when trying to run the test I get following error.
python -m speech_recognition
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 163, in _run_module_as_main
mod_name, _Error)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 111, in _get_module_details
__import__(mod_name) # Do not catch exceptions initializing package
File "/usr/local/lib/python2.7/site-packages/speech_recognition/__init__.py", line 5, in <module>
import io
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Try going to terminal and typing in that:
python -m speech_recognition
or
python3 -m speech_recognition
If that's what your running.
it depends what version of python your using, Sierra comes with python IDLE 2.7.10 already installed.
if you download those modules for python it will download them to work with 2.7.10 not the 3.0 + you might be using.
so if you downloaded python3 and are trying to run it with python3 it won't work, only from 2.7.10 so try typing in.
python -m speech_recognition
Like i suggested and see if it works in the terminal, if it does then it means i was right and python 2.7.10 will work with it.
What do I do wrong?
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==7.1.0', 'console_scripts', 'pip')()
File "/usr/local/lib/python3.4/dist-packages/setuptools-18.1- py3.4.egg/pkg_resources/__init__.py", line 558, in load_entry_point
File "/usr/local/lib/python3.4/dist-packages/setuptools-18.1-py3.4.egg/pkg_resources/__init__.py", line 2682, in load_entry_point
File "/usr/local/lib/python3.4/dist-packages/setuptools-18.1-py3.4.egg/pkg_resources/__init__.py", line 2355, in load
File "/usr/local/lib/python3.4/dist-packages/setuptools-18.1-py3.4.egg/pkg_resources/__init__.py", line 2361, in resolve
ImportError: No module named 'pip'
Stackoverflow asked me to type more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more and more
Try to fix pip installation with:
sudo apt-get install python3-pip
I've had the same issue and this worked for me. Maybe it's because you only installed pip for an earlier version of python or you intalled it from source and not from you distributions package management.
It sounds like your pip variable isn't set or you're trying to use conflicting environments. If you want to get the python package pymongo installed on your 3.4 version look to use:
/usr/local/bin/pip3.4 install pymongo
Then you can verify by testing in the 3.4 interpreter by running:
python3.4
>>>import pymongo
>>>
In the future look at using virtualenvs, they can be really easy and clean to work with while controlling your packages neatly. Hope this helps!
I'm trying to use PushBullet.py which uses python-magic which in turn uses libmagic.
I have followed the dependencies instructions and installed Cygwin and copied the three files to Windows\system32 directory but still getting the following error:
Traceback (most recent call last):
File "C:\New Python ActiveX Scripting Engine.py", line 1, in <module>
from pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\__init__.py", line 2, in <module>
from .pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\pushbullet.py", line 4, in <module>
import magic
File "C:\Python27\lib\site-packages\magic.py", line 161, in <module>
raise ImportError('failed to find libmagic. Check your installation')
ImportError: failed to find libmagic. Check your installation
EDIT
If I put cygmagic-1.dll OR cygz.dll into C:\Python27\ and rename it to magic.dll I get the following error:
Traceback (most recent call last):
File "C:\New Python ActiveX Scripting Engine.py", line 1, in <module>
from pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\__init__.py", line 2, in <module>
from .pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\pushbullet.py", line 4, in <module>
import magic
File "C:\Python27\lib\site-packages\magic.py", line 143, in <module>
libmagic = ctypes.CDLL(dll)
File "C:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found
If I put cygwin1.dll into C:\Python27\ and rename it to magic.dll I get the following error:
Traceback (most recent call last):
File "C:\New Python ActiveX Scripting Engine.py", line 1, in <module>
from pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\__init__.py", line 2, in <module>
from .pushbullet import PushBullet
File "C:\Python27\lib\site-packages\pushbullet\pushbullet.py", line 4, in <module>
import magic
File "C:\Python27\lib\site-packages\magic.py", line 185, in <module>
magic_open = libmagic.magic_open
File "C:\Python27\lib\ctypes\__init__.py", line 378, in __getattr__
func = self.__getitem__(name)
File "C:\Python27\lib\ctypes\__init__.py", line 383, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'magic_open' not found
I'm doing this on Windows 7 64bit running Python 32bit 2.7.8 (fresh install today to try and resolve this problem).
Does anyone know how to resolve the problem?
EDIT: Tried on a further 5 different windows computers and all 5 have the same problem(s).
I had the same problem with python-magic and solved it by fixing the following line in the magic.py file (C:\Python27\lib\site-packages\magic.py in my PC):
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1')
Since I've installed libmagic from Cygwin, the DLL was named cygmagic-1.dll. So I simply added another choice in the previous line:
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') \
or ctypes.util.find_library('cygmagic-1')
Don't forget to add cygwin\bin to your PATH.
EDIT:
It seems that this issue has been addressed on the GitHub repository.
EDIT2:
These are the steps I followed to make PushBullet.py work on my machine:
Install PushBullet.py via pip (pip install PushBullet.py);
Install libmagic from Cygwin;
Add C:\cygwin\bin\ to the PATH environment variable;
Change the magic.py file as I've explained above. (In my case the error was on line 139)
From the Windows paths in your traceback listings I guess that you are trying to execute PushBullet script from Windows version of Python. Why did you install Cygwin if you are not using it? Python for Windows really won't use Cygwin's DLLs.
You have to execute PushBullet.py from Cygwin using a Python for Cygwin, not from Windows Console using a Python for Windows. That means execute for example bash (something like C:\cygwin64\bin\bash.exe --login -i) and from bash execute PushBullet script: python PushBullet.py.
It expects, that you have Python and python-magic for Cygwin (for Cygwin! not Windows version) already installed.
Copying DLLs to your system directories is nonsense, don't do it. Renaming them is uber-nonsense. How did you expect it could work? Each library is specific, you can't just rename it to change how it works internally.
I'm already using PushBullet for some time, so I was interested in this particular Python script. I'm also using the Cygwin for years. So I have installed PushBullet library:
pip install pushbullet.py
Then I have created very simple script test.py:
#!/usr/bin/python
from pushbullet import PushBullet
pb = PushBullet('my_access_token')
success, push = pb.push_note("Testing title", "Hello world!")
When I executed it using ./test.py I got an error message, that I'm missing magic library, so I installed python-magic library using Cygwin's setup utility.
I executed it again and voila - I have "Hello world!" message on my phone. Done.
Just a note again: I have executed it from the Cygwin's shell (zsh, but you'll have bash I guess), not from Windows Console. I also didn't use Python for Windows but Cygwin's version. Don't mix Windows and Cygwin executables!
So dumb-proof steps would be:
download and execute setup.exe from Cygwin.com
install python and python-magic
execute Cygwin's shell (you can execute "Cygwin Terminal" from your Start menu or just execute C:\cygwin64\bin\bash.exe --login -i for example from "Run" dialog or Windows Console)
install pip (see for example Pip install not functioning on windows 7 Cygwin install)
install PushBullet library: pip install pushbullet.py
prepare your testing script
execute it: python testing_script.py or just testing_script.py if it contains the shebang line and is executable
it should work, if not, post your errors, please
Thank you for a tip to useful library :)
You cannot mix Cygwin and MSVCRT binaries. Therefore, in order to use python-magic with the Windows Python, you must get a Windows-compiled libmagic and fix magic.py to find the libmagic DLL.
Otherwise, if you want to use Cygwin's python-magic as-is, you need to use Cygwin's python packages.
I created a virtualbox with a fresh install of ubuntu 9.10.
I am trying to get MySQLdb to run on python but I'm failing at the import MySQLdb
I first tried sudo easy_install MySQL_python-1.2.3c1-py2.6-linux-i686.egg and then sudo apt-get install python-mysqldb.
Both apparently installed ok, but gave me the following error message when in python I have the import line:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/MySQLdb/__init__.py", line 19, in <module>
File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/_mysql.py", line 7, in <module>
File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory
I have already installed MySQL and it is running, if that matters at all.
I tried following this, but failed in step 2
Your MySQLdb egg installation looks like it is not working properly. You should go into /usr/local/lib/python2.6/dist-packages and remove it.
The Ubuntu python-mysqldb package should work fine. Unless you have a good reason, you should stick to your distribution's package manager when installing new software.