I have a package I am installing in Python that requires dependancies or it fails to install:
> pip install http://etc
pak/test.cpp:3:10: fatal error:
'tools/test.cv' file not found
#include "tools/test.cv"
I have been infomred that I need to download the files (which I have done) then...
create a file ~/.tools.cfg containing:
[build_ext]
include_dirs=/path/to/home/tools
However, I don't understand this last part!
How does the pip installer pick up the .tools.cfg file, where do I even create the file .tools.cfg?
I'm running this on a mac if thats makes a difference.
According to the path you gave, you make the file in your home directory. On a Mac (OS X, I assume), that is a sub-directory of /Users named for your user name (i.e. /Users/Sputnik). You can create it with any text editor, i.e. emacs, vim, nano, TextEdit.app, etc.
I don't know exactly how the pip installer is looking up that file, but presumably it's looking for a file with the name of the package (in this case, tools).
Please comment if this doesn't answer your question, and accept (i.e. click on the Checkmark) if it does!
Related
I do not remember since when, but whenever I install any pip based package, my system (Ubuntu 14.04, Python 2.7.6) trows a warning/error :
Url 'file:///home/username/.pip-wheelhouse' is ignored: it is neither a file nor a directory.
I don't know where this line came from but the pip package I'm installing installs very well, but this line is always shown. How can I remove this ?
There are a few things that can cause this. First take a look at your pip configuration file at ~/.pip/pip.conf and see if it contains a section like this:
[wheel]
wheel-dir = /home/username/.pip-wheelhouse
If so, comment that section out, use pip, and see if that gets rid of the message.
This config file specifies the same information as some environment variables. Try this:
env | grep -i wheel
This command will list all of your environment variables that contain the word wheel. If you see any output, look for a line that specifies the .pip-wheelhouse directory. For example, PIP_FIND_LINKS is the top suspect. When you've found the culprit and you just need to track down where those variables are getting set. The top candidate files for setting variables like that would be ~/.bashrc, ~/.profile, and /etc/profile. Search those files for the word wheel and I suspect you'll be able to resolve this.
I am testing out how simple Apache Thrift is to learn and it looks promising. One major problem: the first tutorial doesn't work...
I have Windows 7, Python 2.7, and got the Thrift .exe for Windows v.0.9.1. I'd rather not compile from source as I don't use Cygwin etc. The exe gave the problems described below. So I moved on and tried using Chocolatey to install Thrift using
cinst Thrift
which worked fine and gave me Thrift v0.9.0. But this version results in the same behavior as the exe, described below.
When I run the tutorial found at http://thrift.apache.org/tutorial/py I get the following:
C:\Users\Me\Desktop\Thrift>thrift -r --gen py tutorial.thrift
[WARNING:C:/Users/Me/Desktop/Thrift/tutorial.thrift:59] Could not find include file shared.thrift
[ERROR:C:/Users/Me/Desktop/Thrift/tutorial.thrift:123] (last token was 'shared.SharedService')
Service "shared.SharedService" has not been defined.
Hopefully the exe works for someone because I'd love to avoid this requiring a build from source.
The answer is that the tutorial assumes you have a /tutorial folder with two .thrift files included in it. If you go the Windows EXE route and then build your tutorial.thrift file, you will also need to add shared.thrift which can be found in Git at https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob_plain;f=tutorial/shared.thrift
Save this file next to your tutorial.thrift file and you can proceed with the tutorial.
The command
thrift -r --gen py tutorial.thrift
uses the -r[recurse] switch to automatically build a second, included IDL file shared.thrift. This shared.thrift file is located in the same folder as tutorial.thrift is. Because Thrift looks for included files based on the current folder, you have to explicitly call the Thrift compiler from that folder.
Assumed, your Thrift working copy is under C:\Thrift and the thrift.exe is reachable via search path, open a command prompt, navigate to that folder and enter the command again:
C:\> cd Thrift\tutorial
C:\Thrift\tutorial> thrift.exe -r --gen py tutorial.thrift
PS: The 0.9.0 is slightly outdated. The 0.9.1 is fine, the forthcoming release 0.9.2 will have even more improvements.
I would like to use scheduler in my python program however I haven't been able to install it.
I tried with Easy_Install and PIP (neither of which I've used before) and I can't find a link for another method. I'm using Python 2.7 on Windows Vista
Since I've never used PIP before I had to install that first. After installing pip I went to command prompt, changed to the directory with pip and typed:
C:\Python27\Scripts>pip install apscheduler
It didn't come up with an error so I assumed it installed, however when I run my python program, which includes the line: from apscheduler.scheduler import Scheduler
it states:
ImportError: No module named apscheduler.scheduler
and when I look at the list of installed modules in Idle it's not there.
It's probably something obvious since I don't have a lot of experience in programming yet.
Help would be much appreciated!
sm
Hi again,
I got it working finally, in the end I didn't use PIP, in case other people need help this is what I did:
Downloaded the apscheduler tar.gz file
Downloaded 7-zip, since this can extract tar.gz files on Windows.
Extracted the tar.gz file using 7-zip, I had to do this twice since the first time I clicked extract it extracted to a .tar file (APScheduler-2.1.2.tar), it was necessary to extract this file as well.
Added C:python27\ to the windows path (this is in control panel->system & maintenance->system->advanced system settings->environment variables)
(I also added C:python27\scripts\ to the path, but not sure whether this makes a difference.
Opened command prompt and moved to the folder containing the extracted APScheduler files including the file named setup.py
In my case this was- C:\Python27\APScheduler\APScheduler-2.1.2\APScheduler-2.1.2\
In command prompt typed> python setup.py install
Hopefully this was everything, perhaps one day I'll delete everything and try again to check, but it took quite sometime to get it going so right now I think I'll leave it as is.
I want to try to develop Cocoa application using Python. I'm new to Mac and I need some help to understand how it works.
First of all I found that I need to install py2app and py2objc. I used easy_install as documented here. There were a few errors with setup tools but eventually py2app was installed. Then I launch "easy_install pyobjc==2.2" and it ended with many errors:
Processing pyobjc-2.2-py2.7.egg
...
Running pyobjc-framework-SystemConfiguration-2.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-ipMzFU/pyobjc-framework-SystemConfiguration-2.2/egg-dist-tmp-odfVol
In file included from Modules/_manual.m:1:
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:19:20: error: limits.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:22:2: error: #error "Something's broken. UCHAR_MAX should be defined in limits.h."
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:26:2: error: #error "Python's source code assumes C's unsigned char is an 8-bit type."
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:33:19: error: stdio.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:35:5: error: #error "Python.h requires that stdio.h define NULL."
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:38:20: error: string.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:40:19: error: errno.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:42:20: error: stdlib.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:44:20: error: unistd.h: No such file or directory
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:56:20: error: assert.h: No such file or directory
...
etc
My questions:
What I need to do to install
py2objc? Unfortunately, I haven't
found a solution for errors, which I
posted previously.
As I understand
there are two kinds of python. One I
installed into Applications folder
(IDLE, launcher), another is the
current Python version supplied with
OS. Can you describe the
difference?
How can I select the
current version of Python used by
Mac OS? And what is the Current
folder in
/Library/Frameworks/Python.framework?
Probably it looks confusing, but this is my first steps! :)
Thank you
Cannot give a definitive answer to that. See comment.
You can install multiple versions of python on your machine (OSX includes a defualt one as you already mentioned). In the applications folder there are some apps to open an interactive interpreter in which you can enter python commands, such as IDLE. These applications use one of the python versions you've got installed. Which brings us to
python_select is the command you want. e.g. python_select -l to list all the python versions you've got installed and python_select python27 to select your own 2.7 version. The Current folder links to the version currently selected via python_select
I've been using virtualenv + pip for python development. I'm not sure what happened, but suddenly whenever I try to run a command-line tool or import libraries, I get this error message:
Traceback (most recent call last):
File "/Users/kyle/.virtualenvs/fj/bin/pip", line 4, in <module>
import pkg_resources
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 698, in <module>
the platform/python version defined at initialization are added.
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 701, in Environment
search_path = sys.path
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 96, in get_supported_platform
'Environment', 'WorkingSet', 'ResourceManager',
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 221, in get_build_platform
if provDarwin:
File "/Users/kyle/.virtualenvs/fj/lib/python2.6/distutils/__init__.py", line 14, in <module>
exec open(os.path.join(distutils_path, '__init__.py')).read()
IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/__init__.py'
From what I can decipher, Python is trying to find distutils_path in the Mac OSX system version Python, not my virtualenv version like it should be.
Not sure why this suddenly started happening. Maybe a recent OSX update? Another possibility is that my hard drive was about to die, so Apple gave me a new one and ran Migration Assistant. Maybe something didn't transferred across correctly?
I encountered this distutils/__init__.py problem when transitioning to OS X 10.7 Lion (from OS X 10.5 Leopard) and using Migration Assistant. I've already installed Xcode 3.2.6 -- thus resolving the missing install_name_tool problem.
Migration Assistant brought over my previous virtualenvs, but since they were based on Leopard's Python 2.5, I figure I need to recreate each of them with the current system Python 2.7.
easy_install was already in the PATH -- probably because it was bundled with Lion's Python 2.7; it seems unlikely to be the result of Migration Assistant. I used easy_install to install virtualenv.
This problem, it seems to me, doesn't have anything to do with Xcode or lack thereof. It's a peculiar line in a file placed in the new virtual env by the virtualenv command:
File "/path/to/my/virtualenv/lib/python2.7/distutils/__init__.py", line 16, in
exec(open(os.path.join(distutils_path, '__init__.py')).read())
IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/__init__.py'
The issue is that, in the Python 2.7 install bundled with Lion, the library doesn't come with .py source files. That directory contains .pyc and .pyo files, but no .py files. virtualenv doesn't seem to expect that.
My workaround is to download Python 2.7 source:
http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
and unpack distutils/__init__.py into the expected place:
sudo tar xvjf ~/Downloads/Python-2.7.2.tar.bz2 --strip-components=2 -C /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7 Python-2.7.2/Lib/distutils/__init__.py
That permits virtualenv to complete successfully, and the resulting Python interpreter seems to run.
Given that the Python 2.7 library bundled with Lion is installed without source, it might seem useful to change virtualenv to try for either distutils/__init__.py or distutils/__init__.pyc ?
> cd /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/
> sudo touch __init__.py
Out-of-the-box python on Lion comes without the python source - just the compiled pyc/pyo files. However virtualenv goes looking for the distutils source file just to confirm where it is. Turns out all we need to do it touch the file it's looking for into existence.
Credits belong to "npdoty" and "Nat Goodspeed".
Turns out the problem was that Migration Assistant, for whatever reason, didn't copy over tools like gcc -- I reinstalled Xcode and things work properly again.
While Migration Assistant doesn't handle things like XCode so well, it is nevertheless designed to transfer some types of applications. It works best with those that exist entirely in the /Applications/ folder or those applications that launch from the /Applications/ folder and do checks for associated files located elsewhere (e.g., /usr/bin/), installing them when they aren't detected on startup.
See http://support.apple.com/kb/HT4413.
I have used a similar approach of Nat Goodspeed.
But I've copied all *.py files.
Download the same version of your system python, 2.7.2 in my case:
$ python --version
Download it and unpack it.
http://python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
# -n copy only missing files, -r recursively
$ sudo cp -rn ~/Downloads/Python-2.7.2/Lib/* /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/