I am trying to run a program I forked off of Github (I will link it if needed to solve this problem)
Basically, the program just has one python file, which I should be able to run. In order to run, there were some other libraries I needed, such as SciKit-Learn. MOst of these seem to be fine, but one of them (Panda 0.8.1) doesn't seem to work. I installed panda just like all the other libraries, and did it a few more times to make sure.
When I try to run the python file, this is the error code I get:
File "C:\Python27\lib\site-packages\pandas\__init__.py", line 15, in <module>
raise ImportError('C extensions not built: if you installed already '
ImportError: C extensions not built: if you installed already verify that you ar
e not importing from the source directory
How do I avoid whatever it is that I'm doing wrong?
Thanks!
Presumably you installed pandas from source. Your problem is that the pandas library - like quite a few others - includes C extensions, on Linux installing from source, i.e. downloading .zip or .tar.gz files, unpacking them and running python setup.py install is all you need to do to get the .c source compiled because everybody already has the necessary tools. On windows you either need to build the C code informing the system that you do have appropriate tools, (after you have got them), or get the built tools from somewhere else.
If you uninstall pandas and go here then locate the pre-built pandas that matches your operating system, python version, etc., download it an run it then your problem should go away.
In general there are two ways of avoiding ever getting this sort of problem:
Look to see if there is a windows installer for the package you are downloading or
Use a sensible OS like Linux
Yeah, building from the source sometimes can be troublesome. Just use a binary version which you can download e.g. from the pandas website:
http://pandas.pydata.org/getpandas.html
Another great possibility is to use a package manager like pip. A one liner in the terminal saves the day (http://www.pip-installer.org/en/latest/installing.html):
pip install pandas
Maybe you already changed to Linux - if so, the simplest way is like for Ubuntu:
sudo apt-get install python-pip
sudo pip install pandas
Related
The server that I am using has an older version of python installed, and I am unable to install packages. Is there a workaround to importing python modules? If I can create my own module and append the directory to be able to import the newly created module, then I am assuming that I should be able to do the same for already built packages. I just need to know how I would be able to install what is required for numpy and then import it using a similar method as when creating modules.
I would recommend that you find a machine to install the same version of Python to match your server. Perform the pip install from that stand alone machine. Do some level of testing to make sure that the code with run with that version of Python and everything is happy. Just the other day I found out the hard way that TensorFlow would now work on the latest Python.
The libraries are being installed for me under c:\users\<profilename>\AppData\Local\Programs\Python\Python36\Lib\site-packages So you could then copy that over to the server.
I found this link that is saying the same thing.
https://superuser.com/questions/943980/is-it-possible-to-install-python-packages-without-a-direct-outbound-network-conn
Good Luck with it.
In short, my question is, how do I install the latest version of scikit-image into my usr/lib/python3/dist-packages so I can actually use it? I think there is a problem with my understanding of how third-party modules are installed. As a newb, I don’t know how to rectify that, hence this post.
I need help to understand how to install packages in python3 up until now I have used pip/pip3/apt-get/synaptic etc and it has worked fine for many packages. However, I have hit several barriers (Skimage, opencv, plantcv in python3). I must emphasise, the problem I am having is using these packages in python3, not 2.7.
For example, I want to use the latest version of scikit-image (0.14) with python3. (http://scikit-image.org/) I have tried using the installation instructions and have not yet successfully managed to install it. I have navigated to my usr/lib/python3/dist-packages and copied scikit-image into this directory (I have all the dependencies installed in here already).
Image of my folder for dist-packages as proof
As you can see, the folder containing skimage is in the directory I want to be installed in, how do I actually install it? Do I have to extract skimage out of the folder into the directory and then run the install command? If I navigate to usr/lib/python3/dist-packages/scikit-image and then run pip install -e . I get an error, stating that I need numpy. If I write a python script using python3 I can clearly see I have it installed (and I have been using it for a long time). So, there must be a problem in how I have this package in my file system. I think a janky workaround would be to copy all the modules into my working directory and Import them that way as if they were modules I have made myself, but this obviously negates the whole point of installing packages.
This has also happened with another package called plantcv. Where I went into the directory usr/lib/python3/dist-packages then cloned the source from git hub and installed as per instructions. When I import plantcv in my python3 script. It Imports fine. But, there is nothing in it, as python cannot see the modules which are inside this folder at usr/lib/python3/dist-packages/plantcv/plantcv.
There is clearly some comprehension here that I am missing, as I have a similar problem for two packages now. Please, Internet. Help me understand what I am missing!
You simply need to copy the folder in /usr/lib/python3/dist-packages/package-name
However, there are certain things that are specific to python packages. The folder named package name should be a valid package. A good indicator of that is it will contain a file "__init__.py". It is very likely that every sub-directory inside this package directory will contain a "__init__.py" file. It depends on whether there are modules inside these sub-directories.
In your code simply import the package like the following.
import package-name
where package-name can be skimage
Why we have to install the python packages before using them?
I am currently working on a small python mysql program. What i tried to download the python connector module from mysql webpage and simply unzip it and place it in the same folder of my code.
And I can import the module properly.
So what is the meaning of installing those packages? Can I use those packages like matplotlib, numpy without installing them ?
Is it possible to have all the required packages installed on a folder so that i can move it to another computer and run my program with only CPython installed (I don't want to install any package on this computer)?
it's not that simple :-)
some packages have dependencies, you also need to download and extract their dependencies (you need pacakge x,and package x uses y) pakcage manager handles that
some package have some c code (they need to be compiled before use (ujson or postgres module) package manager handles that
when your share your code instead of sharing dependencies you simply add a file containing the list of dependencies (requirements.txt) and other user can simply install all dependencies using package manager
Installing a python package enables us to use it anywhere on our system. If we just place the package in the same directory as our script then it may well work, but only for scripts in that directory.
Some packages also rely on others to function properly, and the installation of a package may well install those pre-requisite packages for you. You may be able to do this manually, but you'd have to put them all in the same directory as your script every time you wanted to run it.
So installing the packages is the easiest way to use them.
You don't have to install them, and in some cases you wouldn't install them on your system; if you had split your code across two files and imported one file at the top of the other for example.
In fact, you don't really need install package on your system.
But if you install it, you can use these packages every where on your system.
Also, you can create a requirement.txt file to enable install all packages that you need on other computer. You can check this manual https://pip.pypa.io/en/stable/user_guide/#requirements-files
What is the correct way to install and update Python packages on OS X Mountain Lion, using Apple's built in Python?
I've tried all everything I can find here and in the documentation for various packages but keep encountering all kinds of errors that result in failed or aborted installations or updates. Notably, with pip I frequently get errors like
RuntimeError: maximum recursion depth exceeded in cmp
or
SError: [Errno 24] Too many open files: '/Library/Python/2.7/site-packages'
and some commands pip commands (like list) just don't seem to exist at all.
I have an uptodate version of pip that works fine with some packages, and have the latest Xcode command line tools installed.
The only thing that seems to work — and it works all the time — is
python setup.py install
Is this the correct way to maintain and install python packages on Lion? Is there any reason not to use this method as my primary method for keeping packages uptodate? Should pip be working for me, or does it not work with Apple's Python?
UPDATE: I spoke too soon. I also have problems with
python setup.py install
Occasionally (often) I'll get:
error: /Library/Python/2.7/site-packages: Too many open files
When nothing is running in a fresh Terminal, I get about 50 when I
lsof | grep python | wc -l
and if I quit Dropbox, which seems to be the source of these, and reduce the number to 0, I still get "Too many open files" for most package installation operations, with whatever tool I use, even after a reboot of my system.
Why am I getting a "too many open files" error so often?
You should be able to maintain exactly as you're doing, but likely need to update your PYTHONPATH to somewhere outside of /Library, hence the reason everyone else is mentioning that and/or using homebrew to install python.
I install python packages with pip and maintain them using:
https://github.com/nvie/pip-tools
First of all, download and install the full Python from the python website.
Then use pip (or homebrew). The built-in python is incomplete in many respects, including mainly, the ability to install new packages. I faced similar problems when I fist got my MacBookPro and installing the full python on top of the built-in one solved all my troubles
Why use Apple's built-in Python? It's incomplete, I think.
I'm using Homebrew and brew install python works fine for me.
From https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python:
We recommend to brew install python because:
Comes with pip (and distribute)
Python (distutils) finds brewed
software (includes, libs), knows about the compiler and flags even if
the command line tools for Xcode are not installed.
No need to set the PYTHONPATH for Homebrew bindings.
No need to work-around the sudo-is-needed-for-easy_install issue
I've been trying to connect opencv and python in both Ubuntu and Windows XP. I've failed on both.
I've read many webpages and threads about "how to install" it but none has worked (the worst part is that they all say kind of the same).
Steps (windows xp):
Installed Python 2.7 by default (works perfectly)
Installed PIL and cx_Freeze (may they
create a conflict? I don't think so
:s)
Installed Opencv 2.2 by default
(OpenCV-2.2.0-win32-vs2010.exe) and
it isn't recognized inside a py nor
as import opencv.cv nor using the
cookbook way, import cv (I skipped
the visual studio steps since I'll
use it with python)
Checked path (it's ok, it has the
Opencv2.2\bin thing)
Rechecked webpages and stuff
Steps (ubuntu):
Had python working
sudo apt-get install, cmake, make,
sudo make install, etcetc (from the
tutorials)
same thing... module not recognized
Please can you help?
Update:
I managed to install it and have it recognized by the system (I used http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv and it worked perfectly after that).
The problem now is that it crashes when I try to use CaptureFromFile. Someone else has reported it 3 days ago so now I wait.
I'll check the other wrappers, maybe one of them will work.
For windows see my web page: http://www.modernmind.org/wiki/OpenCV
For Ubuntu you should just need to apt-get install python-dev then generate the make files with Cmake, build it and then make install. In order to build the python bindings you need to have the python header files on your system and you probably don't. When you run configure in Cmake make sure that you don't see any messages at the top about PYTHON_INCLUDE not being defined.
To access a library it needs a Python library installed in the Python version you are using. From what you write above it seems to me that you install OpenCV in general, but that you don't specifically install the Python library. This is why it doesn't work.
I'm not sure how to install the Python wrappers, and the OpenCV documentation is a bit sparse on that info. But if you did build them (and that needs to be turned on explicitly, says the docs) they seem to end up in opencv/release/lib .
Look at "Testing Python wrappers" on http://opencv.willowgarage.com/wiki/InstallGuide
If there is still no luck, there is a bunch of alternative Python wrappers available: http://pypi.python.org/pypi?%3Aaction=search&term=opencv&submit=search
Maybe they are better documented.