I've been having very serious issues installing Basemap from mpl_toolkits. Fortunately, it looks like I'm not the only one having these issues... I was wondering if someone could help me here.
I'm currently running OS X 10.10 (Yosemite).
Long story short, I was able to install Basemap via Anaconda after much difficulties. Now whenever I try to import Basemap, I get the following error:
28 from matplotlib.lines import Line2D
29 from matplotlib.transforms import Bbox
---> 30 from mpl_toolkits.basemap import pyproj
31 from mpl_toolkits.axes_grid1 import make_axes_locatable
32 from matplotlib.image import imread
ImportError: cannot import name pyproj
...which doesn't make sense to me at all. I have pyproj installed, and I physically see it in my Anaconda pkgs folder. It's called pyproj-1.9.3-0. I also have basemap-1.0.7-np19py27_0 in my pkgs folder.
Does anyone have any idea what's going on? Maybe I stupidly forgot to do something? Sorry if it's a dumb question - I'm an amateur when it comes to these sorts of things.
I just managed to install Basemap on Yosemite with Anaconda without any problems, so maybe there's something unusual about your set-up (what issues are you refering to?)
What I did was simply
conda install Basemap
But here are some things to think about:
Did you install anything after issuing this command (on my system, conda updated my matplotlib to 1.4.3 as part of this installation. You could try conda update, but you might need to do some fixing if you changed anything "by hand".
Are you using the right virtual environment (the one from which you installed Basemap)?
import Basemap with from mpl_toolkits.basemap import Basemap rather than the import Basemap that your question implies: see e.g. this example.
type which python and check that the output is along the lines of
/Users/<username>/anaconda/bin/python
or
/Users/<username>/anaconda/envs/<virtual-env>/bin/python
and that you're not using your Mac's system Python which would be something like
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python
Related
I'm trying to run a code in python2.7 on windows os that uses sentiment analysis
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
analyzer = SentimentIntensityAnalyzer()
and I'm getting this error
ImportError: No module named vaderSentiment
Can anyone help me with this?
Assuming you solved this one as it's from 7 months ago, but for anyone else searching for it:
Go into terminal/cmd and paste the following:
pip install vaderSentiment
More info on VADER: https://github.com/cjhutto/vaderSentiment
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
#note: depending on how you installed (e.g., using source code download versus pip install), you may need to import like this:
#from vaderSentiment import SentimentIntensityAnalyzer
read the comment in a code
Try running your file with Python3 instead of just python. Sometimes when you have different pips/pythons installed on your computer you might have vaderSentiment installed in python2 when you need to run it in python3.
I would like to have a script invoke numpy from a c++ embedded python runtime by setting the runtime path to know about the numpy module located within site-packages.
However I get the error:
cannot import name 'multiarray'
from \Lib\site-packages\numpy\core__init_.py on the line
from . import multiarrray
I have tried to set the os.path to be xxx\numpy\core but it still cannot seem to find the multiarray.pyd file during the import statement
I have read through similar questions posed but none of the answers seem relevant to my case.
I am using Python 3.4.4 (32 bit) and have installed Numpy 1.11.1 using the wheel
numpy-1.11.1-cp34-none-win32.whl
python -m pip install numpy-1.11.1-cp34-none-win32.whl
Completed without any errors.
Seems like the failure message maybe more general than just an incomplete PYTHONPATH?
Also think it might be broader than Numpy in that ANY .pyd based package that is imported from the embedded environment will have this problem?
Any help appreciated.
Did you ensure all your NumPy includes: \numpy\core\include\numpy\ were present during the build? That's the only time I get those types of errors was if the build couldn't find all the NumPy includes... although during embedding I found that the numpy entire directory (already built on your build machine) has to be inside a directory under Py_SetPath(python35.lib;importlibs); assuming importlibs is a directory with NumPy inside and anything else you want to bundle.
Seems like the answer was to install python 3.4.1 to match the python34.dll version of 3.4.1.
I'm running Python 2.7.11 under Anaconda 2.0.0 (x86_64) on a MacBook.
Some weeks ago, as part of a process of getting OpenCV working, I downgraded numpy from wherever it was (unfortunately/stupidly I have no record) to 1.7.1. I seem to remember this was necessary, and I do not want OpenCV to stop working, so I'm pretty sure I should now leave numpy where it is.
However, today I discovered that this has broken my matplotlib/pylab. When I do import pylab I get the following:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 9 but this version of numpy is 7
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
...
...
ImportError: numpy.core.multiarray failed to import
My question, therefore, is: how do I install (or roll back to) a version of matplotlib that's compatible with my existing numpy, without disturbing my existing numpy?
Here's where I've got so far: based on related conda questions on SO, I looked at the output of conda list --revisions matplotlib which includes:
...
2016-03-28 17:16:36 (rev 6)
conda {3.8.3 -> 4.0.5}
conda-env {2.0.1 -> 2.4.5}
numpy {1.8.1 -> 1.7.1}
...
Now I'm not sure how to interpret this but given the numpy version number looks like it's actually falling in contrast to all the other entries here, this sounds to me like a promising, "in March 2016 matplotlib realized it could fall back to an earlier version of its numpy dependency". However, when I ask for this revision:
conda install --revision=6 matplotlib
I'm told I already have it, and that its dependency is numpy 1.8:
Fetching package metadata: ....
# All requested packages already installed.
# packages in environment at /Users/jez/anaconda:
#
matplotlib 1.3.1 np18py27_1 <unknown>
So from here I'm not sure how to proceed. I've tentatively played with some variations on conda install matplotlib, but it clearly wants to mess with my numpy at the same time, so I have never pressed y. Equally clearly, I'm out of my depth in conda, so would really appreciate your help.
You can specify the exact versions of any libraries you want in the conda install command. For example:
$ conda install numpy=1.7.1 matplotlib=1.3
If the versions are incompatible, the command will give you an error specifying exactly what the incompatibility is.
OS: CentOS 6.6
Python 2.7
So, I've (re)installed Canopy after it suddenly stopped working after an abrupt shutdown. It worked fine immediately after the install (I installed as my default Python). But after one reboot, when I try to open it with /root/Canopy/canopy (the icon under applications no longer works, either), I get the following error:
(Canopy 64bit) [xxuser#xxlinux ~]$ /root/Canopy/canopy Traceback (most recent call last): File "/home/xxuser/qiime_software/sphinx-1.0.4-release/lib/python2.7/site-packages/site.py", line 73, in <module>
__boot() File "/home/xxuser/qiime_software/sphinx-1.0.4-release/lib/python2.7/site-packages/site.py", line 2, in __boot
import sys, imp, os, os.path ImportError: No module named path
I found this link: Python - os.path doesn't exist: AttributeError: 'module' object has no attribute 'path', but both of my os.py and os.pyc were 250 and 700 bytes, respectively. There was another file called site.py which was 0 bytes and site.pyc was about 100 bytes. What are these files? And would deleting them hurt anything (which is what they did)? And why is this happening after reboot? (using reboot command).
I also found this: https://groups.google.com/forum/#!topic/spyderlib/hKB15JYyLqM , which could be relevant. I've updated my python path before with sys.path.append('/..')
My guess is that for some reason os.path isn't in sys.path? and __boot can't find it? But I'm new to Python and Linux and want to know what I'm doing before I go modifying any boot files, paths, etc.
Thanks in advance.
More information (saw that I'm supposed to update new info in an edit to original question. New to this.)
From one of the comments:
This is what I got:
import os.path
import posixpath
os.path
module 'posixpath' from '/home/xxuser/qiime_software/python-2.7.3-release/lib/python2.7/posixpath.pyc'
posixpath
module 'posixpath' from '/home/xxuser/qiime_software/python-2.7.3-release/lib/python2.7/posixpath.pyc'
Looks like os.path is there.
Could this have to do with a permissions error? I have it installed to /root/Canopy/canopy and I found this: docs.python.org/2/library/os.html#module-os (section 15.1.4). Does that make sense?
I'm also not sure if the following is related, but it might possibly. I can no longer seem to update my path with sys.path.append('/file/path/here'). It works until I close the terminal, then I have to re-append the next time I want to call a module from the new directory. Are sys.path and os.path related in any way?
Just fixed this on OSX with:
brew uninstall python
brew install python
No idea why, never seen it in 5 years of working with Python :S
It turns out that I was onto something with my last comment.
I'd downloaded a bunch of biology modules that depend on python, and so many of them came with their own install. When I added the modules to ~/.bashrc, my bash began calling them in advance of my original CentOS install. Resetting ~/.bashrc and restarting (for some reason source ~/.bashrc didn't work) eliminated all of the extra stuff I'd added to my $PATH and Canopy began working again. I'm going to go through and remove the extra installations of python and hopefully the issue will be behind me. Thanks to everyone who posted answers, especially A.J., because that's what got me thinking about .bashrc .
Edit: With some better understanding, this was all because of using python in a virtual environment. Canopy was resetting my path every time I opened it. I'm using a self-installed virtual environment now and have configured my path.
Try seeing if you have posixpath by typing import posixpath:
>>> import os.path
>>> os.path
<module 'posixpath' from '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc'>
>>> ^D
bash-3.2$ python
>>> import posixpath
>>> posixpath
<module 'posixpath' from '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc'>
>>>
Im completely new to pygame. after installing it and looking at a tutorial, the first code block i ran (from the tutorial) took me to the pygame modlule, and said that pygame.base could not be found.
it couldn't find any of these at all:
from pygame.base import *
from pygame.constants import *
from pygame.version import *
from pygame.rect import Rect
from pygame.compat import geterror
import pygame.rwobject
import pygame.surflock
import pygame.color
that's from the pygame module.
I looked in both the pygame files that were installed and saw files with those names, though i could not open them (unknown file type)
i installed the python 2.7 binary for windows version of pygame, and used the installer. everything looks like it's in the right place as far as i can tell.
It doesn't seem that you have pygame properly installed. Can you even successfully run import pygame?
Are you sure you only have one copy of python installed?