With
"source activate graphlab"
in the terminal I can start up graphlab.
I've created it like this: "conda create -n graphlab python=2.7 anaconda", because using virtualenv with Anaconda is untested and not recommended (according to the warning in the terminal, I don't know whether this really is the case.).
After starting up graphlab the terminal shows:
discarding /Users/username/anaconda/bin from PATH
prepending /Users/username/anaconda/envs/graphlab/bin to PATH
But when I want to import graphlab in the Spider IDE it shows the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/username/anaconda/lib/python3.4/site packages/spyderlib/widgets/externalshell/sitecustomize.py", line 580, in runfile
execfile(filename, namespace)
File "/Users/username/anaconda/lib/python3.4/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 48, in execfile
exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
File "/Users/username/Documents/projectname/pythonfile.py", line 3, in <module>
import graphlab as gl
ImportError: No module named 'graphlab'
How can I solve this? I am totally new to installing these things, so hopefully someone can help me with an extensive step by step explanation.
The Dato Graphlab Create installer did not actually install graphlab on my Mac (El Capitan). I did the following (Anaconda is installed) in a terminal window:
% pip install graphlab-create
That subsequently installed Graphlab Create. You can then easily verify:
% python
Python 2.7.10 |Continuum Analytics, Inc.| (default, Sep 15 2015, 14:29:08)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import graphlab
>>>
I've noticed that occasionally, Python will forget that Graphlab Create is installed. A repeat of the above 'pip' command will cause it to remember.
python anaconda graphlab
Open Anaconda command prompt. Run the following command:
pip install graphlab-create
The Spider IDE seems to be configured to use Python3.4 by default. That has to be changed to 2.7. This is from the error message on the issue.
There seems to be an issue with the Spider IDE.
Try importing from the command line interpreter (Anaconda version) and it should work fine.
Got the same error message, although I for sure had installed GraphLab on an environment with conda on Windows. I solved it with kernels for different environments.
Do the following on command line:
activate myenv
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
replace myenv in the code above with the name of the (conda-)environment in which graphlab is installed
Source (kernels for different environments): https://ipython.readthedocs.org/en/stable/install/kernel_install.html
Oh and to be sure that you actually had installed graphlab correct in your environment in the first place, you can test this by doing in command line:
Change environment:
activate nameofyourenvironment
Start Python:
python
Check in Python if GraphLab is found:
import graphlab
(if you don't get an error message, you did install graphlab correct in that particular environment)
Related
System:
System Version: macOS 10.15.7 (19H1030)
Kernel Version: Darwin 19.6.0
conda version: 4.10.1
VS Code version: 1.56.2
I open the VS Code terminal, create a conda environment and activate it:
conda create -n foo python=3.6
conda activate foo
I install pandas and check that the installation was successful:
conda install pandas
conda list pandas
# packages in environment at /opt/anaconda3/envs/foo:
#
# Name Version Build Channel
pandas 1.1.5 py36hb2f4e1b_0
Simple script test.py to test that everything is fine:
import pandas
print(pandas.__version__)
So far, so good. With the foo environment still active, I run
(foo) ...:~ <username>$ python test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
import pandas
ImportError: No module named pandas
...Not so good anymore. The issue is that,even though the conda environment is active and the corresponding Python interpreter is selected in VS Code,
the terminal insists on using the system Python intepreter, for which pandas is not installed:
(foo) ...:~ <username>$ python
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.
Python 2.7.16 (default, Jun 5 2020, 22:59:21)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pandas
>>>
Neither conda init bash, conda init or source ~/.bash_profile solved the issue. How can I get VS Code to actually use my conda env when running stuff in the terminal? I'm pulling my hair out on this.
PS note that if I use a better Mac terminal emulator (e.g., iTerm2), instead of the VS Code terminal, everything works fine.
(foo) ...:~ <username>$ conda activate foo
(foo) ...:~ <username>$ python test.py
1.1.5
I created a fresh conda environment for using scikit-learn and used
conda install <package> to install scikit-learn, jupyter, pandas, etc. for compatible dependencies..
I checked if sklearn was working after loading the environment:
$python
Python 3.7.4 (default, Aug 13 2019, 15:17:50)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
>>>
Since import command didn't throw errors, sklearn is ready for use. However, I am getting a ModuleNotFoundError while trying to import it in a jupyter notebook, that I am running from the same environment.
import sklearn
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-b7c74cbf5af0> in <module>()
----> 1 import sklearn
ModuleNotFoundError: No module named 'sklearn'
I was able to import numpy and pandas in the same notebook without any errors.
Please help me understand the problem and how to troubleshoot it.
Best practice: Install everything via conda or pip3, as mentioned in this answer.
If that didn't work, check the system paths in jupyter notebook:
import sys
sys.path
and the system executable:
sys.executable
These must correspond to the python in your current loaded environment.
For me, the issue was with the jupyter Notebook's kernel. See the kernel specifications in kernel.json file in the path. You can find the directory for this file from jupyter kernelspec list. I manually changed the python path to the python in my environment (this is a bad idea, but it worked).
Make sure that your jupyter notebook is finding the same version of python as your terminal, otherwise installing modules with conda install in your terminal won't show up in your notebook. Do
import sys
print(sys.version)
in your notebook and in your terminal. If they do not match up, then add your terminal's python version to your notebook:
conda install nb_conda_kernels
conda install ipykernel
and then in the notebook switch to the kernel you just installed (kernel -> change kernel)
Check your path for Python and Jupyter:
import sys
sys.path
You may find different results from Python and Jupyter. This can be fixed temporarily by appending this line of code if you are using macos:
sys.path.append('/Users/**your_user_name**/anaconda3/lib/python3.7/site-packages')
If you want to solve this permanently, you can create an iPython profile and fix it there.
First activate the finds environment, second launch jupyter notebook, third import sklearn. Inside jupyter notebook.
I have also found the same issue
ModuleNotFoundError: No module named 'sklearn'
but after searching I found its best solution.
You should also try the following steps:
Step 1:
open "cmd"
Step 2:
write "pip install notebook"
Step 3:
After installation of notebook, write "jupyter notebook " in cmd.
Tell me if you got your solution
thank you!
I've installed jupyter-hub on my machine that was running smoothly with jupyter-lab, conda and python3.6.
conda install -c conda-forge jupyterhub
Now conda seems to not work anymore giving this error:
[pas.datascience_dev#devrmdatasci01 site-packages]$ conda
Traceback (most recent call last):
File "/data/pyconda3/bin/conda", line 12, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
Now if i run python, it seems to use python3.7 packaged by conda-forge
[pas.datascience_dev#devrmdatasci01 python3.6]$ python
Python 3.7.3 | packaged by conda-forge | (default, Mar 27 2019, 23:01:00)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
If i go to my python installation path i can see both a directory python3.6 and a directory python3.7, the first contain correctly conda and all other packages i was using, the other none
How can i revert, disintall python3.7 or stop using it and recode all to use the old python3.6 that was working correctly?
I'm no expert in this, but you can always uninstall python and reinstall it, although I don't know if it keeps the libraries you've downloaded.
my suggestion is run pip install conda, although I'm not sure how it works on Linux.
Note - I already check numpy import error related threads but none helped
I am using debian 8 where default python is 2.7.9. I installed python 3.4.2 and created virutal env.
Within virtual environment -
python -V
Python 3.4.2
pip -V
pip 1.5.6 from /path/venv34/lib/python3.4/site-packages (python 3.4)
I have python3 numpy package - python3-numpy_1.12.0-2~pn0_amd64.deb
which I have installed with sudo dpkg -i python3-numpy_1.12.0-2~pn0_amd64.deb
which successfully completed.
Now when I do
python
Python 3.4.2 (default, Feb 7 2019, 06:08:06)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>>
Any clue what's wrong here?
python3.4 -m pip install numpy==1.12.0-2
ok since my repo is less than 50 i can not add comments, so take this answer as a comment to your question.
I think numpy is installed but not in your virtualenv, make sure your virtualenv is active when you are trying to install any library, you will see virtualenv name in every command line if it is activated.
(venv) C:\Users\seventeen\sprint25>
Try python -m pip install numpy==1.12.0. This should help you.
dI have installe numpy on ubuntu by executing
sudo apt-get install python-numpy
while executing on terminal I get this error.
>>> import numpy as np
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>>
why this is happening? I tried many a times by going through internet but I couldnt find a solution.Could you please tell me how to solve this?
Edit1:
I came to know that I have to install numpy for the python version which I run on terminal, using pip.. Python 2.7.3 runs when I enter 'python' on terminal. So that means I have to install numpy for python 2.7.3. Can someone guide me how to do it? I couldnt figure it out by myself. BTW I am using Ubuntu 12.04 if that helps.
Edit 2:
I did some more digging into this.. my /usr/lib contains two directories python2.7 and python3.While Python2.7 directory consists of a large number of files and sub directories,python3 directory has only dist-packages subdirectory which consists of deb_conf.py anf lsb_release.py..I think I tried python3 few months back and then removed it..But right now python2.7 is the only thing i am having.
Edit 3:
SO here are the outputs of the commands you asked me to enter
~$ virtualenv --no-site-package -p /usr/bin/python2.7 my_env
Running virtualenv with interpreter /usr/bin/python2.7
The --no-site-packages flag is deprecated; it is now the default behavior.
New python executable in my_env/bin/python2.7
Not overwriting existing python script my_env/bin/python (you must use my_env/bin/python2.7)
Installing distribute..............................................................................................................................................................................................done.
~$ source my_env/bin/activate
~$ pip install numpy
last command gave a generated a lot of logs which ended with something like this..
Creating build/scripts.linux-i686-2.7/f2py2.7
adding 'build/scripts.linux-i686-2.7/f2py2.7' to scripts
changing mode of build/scripts.linux-i686-2.7/f2py2.7 from 664 to 775
changing mode of /home/sandeep/my_env/bin/f2py2.7 to 775
Successfully installed numpy
Cleaning up...
After all these I tried to run python again and this is the output.
~$ python
Python 2.7.3 (default, Jan 20 2013, 21:40:19)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>>
In case nothing works.
Install python-virtualenv if it's not yet done.
Create a virtual env
virtualenv name
Start the virtualenv
source name/bin/activate
Install numpy with easy_install or pip
Profit
Note:
Virtualenv activation has to be done everytime. But you can make that task easier with virtualenv wrapper.
http://virtualenvwrapper.readthedocs.org/en/latest/
There are a lot of reasons to use virtualenv instead of ubuntu packages. In some way, I recommend not touching as much as possible the "OS" python. And if you need it for a project, use virtualenv. Python in virtualenv won't mess with other apps and you don't have to use sudo to install new packages.