I want to use matplotlib from my Sublime Text 2 directly via the build command.
Does anybody know how I accomplish that? I'm really confused about the whole multiple python installations/environments. Google didn't help.
My python is installed via homebrew and in my terminal (which uses brew python), I have no problem importing matplotlib from there. But Sublime Text shows me an import Error (No module named matplotlib.pyplot).
I have installed Matplotlib via EPD free. The main matplotlib .dmg installer refused to install it on my disk, because no system version 2.7 was found. I have given up to understand the whole thing. I just want it to work.
And, I have to say, for every bit of joy python brings with it, the whole thing with installations and versions and path, environments is a real hassle.
Beneath a help for this specific problem I would appreciate any helpful link to understand and this environment mess.
I had the same problem and the following fix worked for me:
1 - Open Sublime Text 2 -> Preferences -> Browse Packages
2 - Go to the Python folder, select file Python.sublime-build
3 - Replace the existing cmd line for this one:
"cmd": ["/Library/Frameworks/Python.framework/Versions/Current/bin/python", "$file"],
Then click CMD+B and your script with matplotlib stuff will work.
Well, this tutorial on how to install matplotlib in brew world helped me:
http://penandpants.com/2012/02/24/install-python/
While experienced problems installing scipy on Mountain Lion, this helped furthermore:
Scipy Installing to Wrong Place on Mountain Lion?
Related
I use sublime text to write python codes, but recently i switched to a new computer. On that computer, first I installed anaconda from https://www.anaconda.com/, then I downloaded sublime text 3, I use the tool-->build system-->new build system on the tool bar of sublime text to associate the anaconda python(/anaconda/python.exe) to sublime. Everything seemed alright, I can import regex and many anaconda packages, but when i import numpy, this error happened ImportError: DLL load failed while importing _multiarray_umath: can't find the module.More detail in the picture posted.enter image description here I tried updating numpy package with conda, didn't work. On my old computer I also have anaconda installed, but I don't remember how I set the association betweent sublime text3 and the python interpreter. On the old computer sublime, it's tool--> build system-->Python, no new built system, so maybe that is the difference... Also on the old computer I have torch installed maybe that's the difference? really need help here
I just changed my computer and it seems like I cannot run my machine learning code anymore. Here are some examples:
main.py file
import matplotlib
...
...
command
File "main.py", line 1, in <module>
import matplotlib
ModuleNotFoundError: No module named 'matplotlib'
Here is just one example of matplotlib. Although I can found this module in pip list, I cannot successfullt plot the graph. Anyone knows why?
Do yourself a favor... before you start installing things and creating symlinks, go install Homebrew. Once you have that installed, use it to install Python3 (it should install under /usr/local/bin). Once that is set, open your .bash_profile ($HOME/.bash_profile`) and add to the end:
PATH=/usr/local/bin:$PATH
Now the Homebrew version of your Python binaries will be found first.
Apple has added an "extra special feature" to MacOS called System Integrity Protection which prevents you from being able to edit / replace files in certain locations, which includes /usr/bin. This means you can't go in there and replace the default Python2 binaries with something newer. Only option is to do what I've suggested, or something similar (well, that or just live with Python2, but that's not a very good option).
EDIT:
Please do not install anaconda and Python from Homebrew (I personally do not like Anaconda, YYMV). Go with one or the other, or unpleasant library conflicts surely will be in your future.
So I am new in Python. I downloaded Anaconda (and Homebrew) and using Terminal on my Mac I confirmed that, say, Numpy is installed:
pip install numpy
to get as a result
Requirement already satisfied: numpy in ./anaconda/lib/python3.6/site-packages
Then opening Python within Terminal I can indeed import the package. The story is not the same once I open IDLE. So when I open it and try to import, say, Numpy I get the following message:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import numpy
ModuleNotFoundError: No module named 'numpy'
I guess there is something I do not know, I assume it is a common rookie problem. Can you help me with this?
Since your IDLE is using Python 3 you should use
pip3 install numpy
to get it installed for the correct Python. If you want to use your default installed Python (2.x) instead, IDLE is located at /usr/bin/. From your terminal you can open it with
/usr/bin/idle
this should have the numpy you installed with pip install numpy
See when you are working with Anaconda it creates its own virtual environment.
Now, If you are new in python on MAC then you might not familiar with Virtual Environment.
I suggest you to download python from the official website www.python.org
or Click here to directly download Python 3.6.2 on your MAC.
Then, Download Pycharm(The Best IDE for Python)
Download the community version for beginner and it is also free.
Pycharm Community Version -> Click Here
And do whatever you want and also must read about Virtualenv
According to me, Pycharm is better then Anaconda's Jupyter Notebook
Wish you good luck and show your creativity in python ! !
Erm... well it appears as though - since you have 2 versions on your computer - that it might be because it imported it into the other file path directory. Now, I've never worked with Mac, but I think if you just specify which pip you want to download from, it might work.
For example, on Windows:
C:\Python34\Scripts\pip.exe install numpy
or if you were doing it for 3.6, you would follow the path to the folder, find pip and install. So, I suggest to install the normal IDLE before any other platform built upon it just because it is easier to import modules and is not as bad to break like yours has.
There can be two issues -
You are using python 2 as a kernel for IDLE, since numpy is installed for python3.6. This will raise an error.
The issue is with anaconda's configuration with IDLE. Anaconda installs numpy in ./anaconda/lib/python3.6/site-packages. If IDLE uses systems default python instead of anaconda's. You will not be able to import numpy.
You can try running this snippet -
import sys
print('\n'.join(sys.path))
to track the location of python exactly.
One of the workaround that I can think of is -
create a virtual environment using anaconda. Something like
conda create -n py352 python=3.5.2 anaconda
and then fire IDLE from your terminal. Though I am not entirely sure, if this works for mac. If it doesn't, let me know the output of -
import sys
print('\n'.join(sys.path))
Beginner here.
I’m trying to use sklearn in pycharm. When importing sklearn I get an error that reads “Import error: No module named sklearn”
The project interpreter in pycharm is set to 2.7.10 (/anaconda/bin/python.app), which should be the right one.
Under default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the “Import error: No module named sklearn”
Does anyone know how to solve this problem?
To make sure you have Scikit-learn package installed on your PyCharm IDE, go to File Menu>Settings and search for Interpreter. Select Project Interpreter, and if you dont see Scikit-learn in the list of packages, click the + sign on the right end. It brings us another window with a search bar, where you can type 'Scikit-learn' and install (see screenshots). I hope this helps.
Screenshots:
,
please notice that, in the packages search 'Scikit-learn', instead 'sklearn'
go to terminal- type python -m pip install scikit-learn
then hit enter.
give it some seconds. It will be done.
Sample Image
Double check your python interpreter. Check whether you have select correct interpreter at the first when you create the project.
Or else you can check your interpreter from the project view under External Libraries.
In your case if you didn't select 2.7.10 (/anaconda/bin/python.app) as your interpreter for the project at the beginning still the program give the same error Import error: No module named sklearn.
Same error occurs to me i have fixed by selecting File Menu-> Default Settings-> Project Interpreter -> Press + button and type 'sklearn' Press install button. Installation will be done in 10 to 20 seconds.
If issue not resolved please check you PyCharm Interpreter path. Sometimes your machine have Python 2.7 and Python 3.6 both installed and there may be some conflict by choosing one.
I had exactly the same problem. I'm using PyCharm with Anaconda3 & Python 3.7, and I've installed other packages into/via PyCharms just fine (such as numpy, scipy, and others). But although scikit-learn (which contains sklearn, that was initially confusing) seems fully installed on my system, including "import sklearn" working outside of PyCharm, I could not get the "import sklearn" to succeed inside PyCharm.
I finally got a python-expert friend to help me. He verified everything was correctly installed on my system and verified that PyCharm was somehow messing up.
We finally determined that the venv (virtual environment) was not including scikit-learn (sklearn) even though I had imported it properly into the Project Interpreter in PyCharms.
Solution: Delete and recreate the VENV, specifically ticking the box Inherit Global Site Packages
See here: https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html
for how to create a new virtual environment and get to that parameter.
SOLVED:
reinstalled Python 3.7.9 (not the latet)
installed numpy 1.17.5 (not the latest)
installed scikit-learn (latest)
sklearn works now!
For Mac OS:
PyCharm --> Preferences --> Project Interpreter --> Double Click on pip (a new window will open with search option) --> mention 'Scikit-learn' on the search bar --> Install Packages --> Once installed, close that new window --> OK on the existing window
and you are done.
I'm currently doing the exercise in "Learn python the hard way".
In this exercise i have to install the lpthw.web frame work.
Having installed pip in windows, i open my terminal and hit
pip install lpthw.web
Everything then ends succesfully.
But when i browse C:\Python27\Lib\site-packages\lpthw.web-1.1-py2.7.egg-info and check the installed-files text i can't see the web.py.
Consequently when i try to import it in a simple script i get ImportError.
I don't have python 3 installed as book suggested for possible cause, so i don't know how to work around it.
Any suggestion?
I checked my path
import sys
sys.path
and saw that every single line was using the panda3d path.
As i was not really using it, unistalling it fixed my problem.
For me it was python version control on raspberry pi
(linux) 2.7 is default and does not work.
follow:
https://learn.sparkfun.com/tutorials/python-programming-tutorial-getting-started-with-the-raspberry-pi/configure-your-pi
have other errors now but the import web loads in python.
cheers!