Since updating from Homebrew Python 2.7.11 (from 2.7.10) I'm suddenly unable to test register my package on PyPi from the PyCharm IDE console.
Running (as an "External Tool")
python -B setup.py register -r pypitest
I now get
Traceback (most recent call last):
File "setup.py", line 22, in <module>
from setuptools import setup
File "/usr/local/lib/python2.7/site-packages/setuptools/__init__.py", line 12, in <module>
from setuptools.extension import Extension
File "/usr/local/lib/python2.7/site-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/usr/local/lib/python2.7/site-packages/setuptools/dist.py", line 16, in <module>
from setuptools.depends import Require
File "/usr/local/lib/python2.7/site-packages/setuptools/depends.py", line 6, in <module>
from setuptools import compat
File "/usr/local/lib/python2.7/site-packages/setuptools/compat.py", line 17, in <module>
import httplib
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 80, in <module>
import mimetools
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
File "/usr/local/Cellar/python/2.7.11/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.11/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.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Process finished with exit code 1
I'm not sure how to proceed. I only get this issue if I execute from within my IDE's console. If I do it directly at the system command line (Terminal on OS X) I have no problems.
OS X 10.11.3; Homebrew Python 2.7.11; PyCharm 5.0.3
tl;dr: Fix this issue by doing one of the following:
type hash -r python, OR
log out and log in.
EDIT: An answer to my related question makes it clear what's happening here. When you install a new version of python, you may need to run hash -r python to tell bash to reset the "cached" location to the python executable.
In my case, I was typing python, which was on my $PATH at /usr/local/bin/python. But bash was still using the old cache location /usr/bin/python. So, the old executable was called, but the new path was provided to python in sys.argv[0]. This means that the old executable was running, but the new sys.executable value caused all the wrong modules to get loaded (including the io module).
I'm having the same problem. I installed python 2.7.11 via an installer from Python.org. Strangely, the issue seems to be related to some subtle difference between how OSX launches python when I invoke it from the shell using the full path vs. using just the word python.
So, for me, this works (invoking python via the full path /usr/local/bin/python):
$ which python
/usr/local/bin/python
$ /usr/local/bin/python -c "import io"
$
... but this doesn't:
$ python -c "import io"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
So, as a workaround, you can try doing the same thing.
Elsewhere, I've posted a separate question about this puzzling behavior. Maybe somehow merely calling python invokes some strange mix of the 2.7.11 executable with the 2.7.10 dylibs??
According to https://github.com/klen/python-mode/issues/634:
I had the same issue, but successfully fixed. In my case I compiled
python and vim with homebrew, when PYTHON_PATH has been specified and
set to one of my dev environments, where I also had some libraries,
including io. Workaround was simple: open new terminal, make sure that
you do not have custom PYTHON_PATH, uninstall python, uninstall vim.
Reinstall both of them.
and
Problem solved.
Culprit is the update from python 2.7.10 to 2.7.11.
If you are using conda package control, simply run "conda install
python=2.7.10" will solve this problem.
This doesn't give the root cause though. Since this happens with _io, this looks like a bug in python 2.7.11 (unlikely, there would be a world-scale outcry and a prompt fix if it was) or some packaging bug or version mismatch specifically with the homebrew version (and maybe some related ones, too).
Try to import _io in the console and if it succeeds, check if it was loaded from the same path.
Reinstall python.
brew unlink python && brew reinstall python
Secure the path
export PYTHONPATH=$PYTHONPATH:/usr/local/bin/
BACKUP and Change the order of "paths" file.
sudo nano /etc/paths
it seems, the order of paths, it is decisive to run python properly. In my case, the result was:
#sudo nano /etc/paths
/usr/bin
/usr/local/bin
/bin
/usr/sbin
/sbin
On my mac, path is like this.
$ which python
/usr/local/bin/python
Now I can run both:
$ /usr/local/bin/python -c "import io"
$ python -c "import io"
I had the same issue, it is successfully fixed by just replacing the _io.so file.
sudo find / -name _io.so
copy the path of the _io.so file which DOES NOT belong to python-2.7.11. For example, copy the path of _io.so which is under python-2.7.5:
/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
Replace the /usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so file with the _io.so that you just found.
This happened to me as well in MacVim. I solved it by making sure :python print(sys.path) is using system Python (e.g. /Library/Python/2.7/...)
Since I installed MacVim via Homebrew, I just did that by:
Spawn a new shell that had which python -> /usr/bin/python. For my case I needed to remove the pyenv line from my .bash_profile. If you installed Python via Homebrew you may want to brew unlink python first
brew reinstall macvim
If your problem is caused by anaconda, it is unnecessary to remove //anaconda directory.
Just open your ~/.bash_profile, find the line
export PATH="//anaconda/bin:$PATH
and comment it out, then restart your terminal session.
Another quick workaround if you don't mind sticking with Python 2.7.10 is to specify the path of the Python interpreter executable that will be used for the virtualenv. On OSX that path is usually /usr/bin/python:
virtualenv venv --python=/usr/bin/python
Can't add comment (?) so this just to share my exp., downgrade to 2.7.10 works fr me.
I got this error after a failed NLTK download, I needed to uninstall anaconda:
sudo rm -rf ~/anaconda
update PATH variable
This happened when I already had tried to create a venv in a folder, and mistakenly was trying to initialize a second one! So I just removed venv directory and re-ran the command. Very likely this is not the answer to this solution, but searching my error brought me here, so it may help some others who are stuck.
I solved this issue by removing the symbolic link that was in /usr/local/bin and copying the actual python binary, that was pointed to by said link, there.
I had the same issue when I tried to use PyCharm. Solved by setting "python interpreter" in project configuration to point to the python virtual env I wanted to use, which was an Anaconda env. Somehow the interpreter path was missing the "anaconda" portion of ~/.../anaconda/.../_io.so. No need to uninstall anaconda.
I am testing scrapy for the first time, and after installing it with the command:
sudo easy_install -U scrapy
everything seems to run ok. However, when I run:
scrapy startproject tutorial
I get the following:
luismacbookpro:~ luis$ scrapy startproject tutorial
Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/Current/bin/scrapy", line 4, in <module>
import pkg_resources
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/pkg_resources.py", line 2711, in <module>
working_set.require(__requires__)
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/pkg_resources.py", line 690, in require
needed = self.resolve(parse_requirements(requirements))
File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/pkg_resources.py", line 588, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: lxml
Any idea about what's going on? As you can tell, I am not proficient at all with OSX, and I am still trying to move from a windows "mentality" to OSX, so I don't know where to add paths, modify settings, dependencies, etc. Not even sure how to perform a clean uninstall and start all over.
Any feedback is appreciated, even your suggestions to use alternative python libraries that can perform the same functionality of scrapy. Thanks!
I think this will solve the error message you're seeing:
sudo easy_install --upgrade lxml
This problem can arise on Macs when you use pip to install some packages and easy_install to install others.
Let us know how you go :)
I used easy_install to install pip, pip to install django, virtualenv, and virtualenvwrapper.
I have just returned to it a few weeks later and django does not seem to work anymore, but more concerning is I can't start the process over again as easy_install is returning the following error:
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 10, in <module>
load_entry_point('setuptools==0.6c12dev-r88846', 'console_scripts', 'easy_install')()
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 318, in load_entry_point
File "/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2220, in load_entry_point
ImportError: Entry point ('console_scripts', 'easy_install') not found
After a good evening of hunting I am stumped as to how to resolve this.
You seem to have a version conflict; note the setuptools-0.6c11-py2.7.egg path, but the /usr/bin/easy_install-2.7 script wants to load 0.6c12dev-r88846 instead.
The latter is a development version; it has the revision number of a subversion repository embedded in the version (dev-r88846).
I suspect you have two python installations; one is the system version (in /System/Library and the other is installed with the python installer into /Library/, and the stub script in /usr/bin/ may be installed with the system python.
If so, there'll be another copy of the stub at /Library/Python/2.7/bin/easy_install-2.7, which should work correctly.
I had the same issue, eventually ended up running the 2.7.3 easy_install by
/opt/python2.7.3/bin/easy_install which worked fine
This question already has answers here:
installing MySQLdb for Python 2.6 on OSX [duplicate]
(4 answers)
Closed 9 years ago.
*My larger problem is that I cannot launch a web application using dev_apperver.py from my command line*
However, I also cannot install MySQLdb as well.
Joes-MacBook-Pro:MySQL-python-1.2.3 MoeJancini$ python setup.py build
sh: mysql_config: command not found
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "/Users/MoeJancini/Desktop/MySQL-python-1.2.3/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/Users/MoeJancini/Desktop/MySQL-python-1.2.3/setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Joes-MacBook-Pro:MySQL-python-1.2.3 MoeJancini$
I have looked at similar questions an navigated other forums but I still cannot get past the setup.py build command. Explicit instructions on how to get MySQLdb working would be useful since I'm a noob. Thank you
It depends on what your source for MySQL is. If you're using MacPorts, you may find that you have to use mysql_config5in order for it to work. Edit site.cfg so that it has the right path. Then again, if you're using MacPorts, you should just sudo port install py-mysql and that will install it for you.
So if you're not using MacPorts, you're probably using the mysql.com packages. In that case, you need to install their Connector/C package, which includes development headers and libraries and mysql_config.
When installing mysqldb on mac osx 10.5:
sudo ../bin/python /Users/Awais/mysqlpython/setup.py install
I get the following error:
Traceback (most recent call last):
File "/Users/Awais/mysqlpython/setup.py", line 15, in <module>
metadata, options = get_config()
File "/Users/Awais/mysqlpython/setup_posix.py", line 32, in get_config
metadata, options = get_metadata_and_options()
File "/Users/Awais/mysqlpython/setup_common.py", line 7, in get_metadata_and_options metadata = dict(config.items('metadata'))
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ConfigParser.py", line 564, in items
raise NoSectionError(section)
ConfigParser.NoSectionError: No section: 'metadata'
It seems that you are installing MySQL for Python but you have to have MySQL installed first. So, first download the MySQL installer from http://dev.mysql.com/downloads/mysql/ and install it and then try installing MySQL for Python.
I am trying port an older Linux server RH EL 5 Workstation to CentOS 6.4 64-bit. One of the two things I have had to do -- because it had been a while since I had built a Python-based MySQL server -- was make sure mysql-devel was installed, and from the menu-software install, as well as MySQL-python was installed.
The advantage to installing MySQL-python this way that the CentOS 6.4 distribution matches MySQL-python-1.2.3-0.3.c1.1.el6.x86_64 matches the version of MySQL installed 5.1.69.
Prior to this, I tried building and installing MySQL-python with no success. In a perfect world, I would figure out why, but, like many things, I am on a deadline, and this worked, and was also recommended in posts I read both on SO and elsewhere.