I installed scikit-learn as well as numpy and scipy with conda for python 3.6. But I am not able to import sklearn in python3.6. What is wrong and how can I fix it?
Here is what I see in conda list:
numpy 1.12.1 py36_0
scipy 0.19.0 np112py36_0
scikit-learn 0.19.0 np112py36_0
And here is the error message I got trying to import sklearn:
Python 3.6.0 (v3.6.0:41df79263a11, Dec 22 2016, 17:23:13)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sklearn'
I'm using OS X and conda 4.3.24.
Related
on Ubuntu 20.04 and I can't import protobuf :
(r-torch) brucezepplin#brucezepplin-HP-ProBook-440-G7:~$ conda list | grep protobuf
libprotobuf 3.17.2 h4ff587b_1
protobuf 3.17.2 py39h295c915_0
(r-torch) brucezepplin#brucezepplin-HP-ProBook-440-G7:~$ python
Python 3.9.7 (default, Sep 16 2021, 13:09:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import protobuf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'protobuf'
any ideas?
The python package for protobuf has a package structure that uses google as an root prefix:
import google.protobuf
from google.protobuf import <pkg-name>
I am now using python with mysql by mysql-python-connector
but there's some problem of module importing.
I import modules like this.
import mysql.connector
import os
import surprise
from surprise import Dataset
from surprise import Reader
from collections import defaultdict
import numpy as np
import pandas as pd
from sklearn import tree
import graphviz
from mlxtend.frequent_patterns import association_rules, apriori
when I import module in the python shell(VScode terminal) like this
Shins-MacBook-Pro:part2 yunnys$ python
Python 3.6.8 (default, Apr 11 2020, 15:36:35)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import surprise
>>> from surprise import Reader
>>>
it works
But when I run my python project
Shins-MacBook-Pro:part2 yunnys$ /usr/local/bin/python3 /Users/yunnys/Desktop/part2/DMA_project2_team00.py
Traceback (most recent call last):
File "/Users/yunnys/Desktop/part2/DMA_project2_team00.py", line 7, in <module>
import surprise
ModuleNotFoundError: No module named 'surprise'
Shins-MacBook-Pro:part2 yunnys$
It says it cannot find the module.. What is the problem?
I use pyenv and when I do $pyenv versions I can see this.
system
* 3.6.8 (set by /Users/yunnys/.pyenv/version)
3.6.8/envs/seminar
3.7.7
3.8.0
seminar
and I can see the modules have already existed.
Shins-MacBook-Pro:part2 yunnys$ pip3 list
Package Version
-------------------------- -------
graphviz 0.14
joblib 0.15.1
mysql 0.0.2
mysql-connector-python 8.0.20
mysql-connector-repackaged 0.3.1
mysqlclient 1.4.6
numpy 1.18.4
pandas 1.0.3
pip 20.1.1
protobuf 3.12.1
python-dateutil 2.8.1
pytz 2020.1
scikit-learn 0.23.1
scikit-surprise 1.1.0
scipy 1.4.1
setuptools 40.6.2
six 1.15.0
surprise 0.1
threadpoolctl 2.0.0
And this is pypath!!
Shins-MacBook-Pro:part2 yunnys$ python
Python 3.6.8 (default, Apr 11 2020, 15:36:35)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/Users/yunnys/Desktop/part2', '/home/user/mymodule', '/Users/yunnys/.pyenv/versions/3.6.8/lib/python36.zip', '/Users/yunnys/.pyenv/versions/3.6.8/lib/python3.6', '/Users/yunnys/.pyenv/versions/3.6.8/lib/python3.6/lib-dynload', '/Users/yunnys/.pyenv/versions/3.6.8/lib/python3.6/site-packages']
>>>
Oh I solve it. I change the python version in the VS code from 3.8.2 to 3.6.8 and it works now!
Is VS code use python in a different version from system?!
Actually I already installed tensorflow by using
$ pip install tensorflow
and it works well when I use
$ python
Python 2.7.15 (default, Jul 23 2018, 21:27:06)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>import tensorflow
>>>
but when I use python3 on command line
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'
>>>
it shows an error, and it shows the same error when I use IDLE
use
pip3 install tensorflow
pip installs to default python directory. pip3 installs to python3
Python newbie here.
I'm trying to do a scraper in Python3, but I'm having problems importing lxml on my Sierra 10.12.
Here's the process and additional info:
$ python3 --version
Python 3.5.1
$ pip3 install lxml
Requirement already satisfied: lxml in /usr/local/lib/python3.6/site-packages
$ python3
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'lxml'
>>>
Am I doing something wrong? Is there any other way to install a module?
I noticed that lxml seems to be installed on python 3.6 folder, even though my python3 version is 3.5.1, is that what's wrong?
EDIT: I tried the same thing with python 2.7 and got the same result.
$ python --version
Python 2.7.10
$ pip install lxml
Requirement already satisfied: lxml in /usr/local/lib/python2.7/site-packages
$ python2.7
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'lxml'
>>>
I installed Pillow using Anaconda but if I cannot load the module (see below). How coudl I fix this?
dhcp-86-216:Python_code Alberto$ pip install Pillow
Requirement already satisfied (use --upgrade to upgrade): Pillow in /Users/Alberto/anaconda/lib/python2.7/site-packages
Cleaning up...
dhcp-86-216:Python_code Alberto$ python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Pillow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Pillow
Import PIL, not Pillow:
import PIL