Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Py3 OSX "Module not found" #211

Closed
BartzLeon opened this issue Sep 2, 2017 · 14 comments
Closed

Py3 OSX "Module not found" #211

BartzLeon opened this issue Sep 2, 2017 · 14 comments
Milestone

Comments

@BartzLeon
Copy link

The installation makes no trouble i get the success message for Py2 and 3.
When trying to import them Py2 makes no trouble but Py3 says
ModuleNotFoundError: No module named 'pyowm'.
Installed via pip2 install pyowm and pip3 install pyowm.
I also tried pip install git+https://github.com/csparpa/pyowm.git@develop but the problem still remains.

(I hade no problem installing it on my Windows.)

@BartzLeon BartzLeon changed the title Py3 OSX Module not found Py3 OSX "Module not found" Sep 2, 2017
@csparpa csparpa added this to the Release 2.8.0 milestone Sep 3, 2017
@csparpa
Copy link
Owner

csparpa commented Sep 3, 2017

Hi @werthd it looks like your installation fails somehow

I need to understand more of your installation and local setup in oder to sort this out: could you please paste back here the outputs of the following shell commands run on your OSX setup?

# get the version of pip3
$ pip3 -V

# check if pyowm is installed through pip3
$ pip3 freeze | grep pyowm

# what python3 exact version
$ python3 -V

# this is fundamental: the list of paths Python imports libraries from
$ python3 -c 'import sys; print(sys.path)'

The output list from the very last command should contain the path in output to the very first command (pip3 -V). I doubt that in your case this is not happening

Anyway, let's have a look at your setup-specific and then we'll see

Thanks

@BartzLeon
Copy link
Author

  1. pip3 -V
    pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
    
  2.  pip3 freeze | grep pyowm
     pyowm==2.7.1
    
  3.  python3 -V
     Python 3.6.2
    
  4.  python3 -c 'import sys; print(sys.path)'
     ['', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages', '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyObjC']
    

Thanks for the fast answer

@csparpa
Copy link
Owner

csparpa commented Sep 3, 2017

Good thanks!

So.. your pip3 executable is in folder /usr/local/lib/python3.6/site-packages but that folder does not appear in output from command n.4

Can you please post here the output of command:

$ pip3 show pyowm

And also, did you sudo when you used pip3 to install PyOWM ?

Thanks

@BartzLeon
Copy link
Author

There is no output when i execute this command and i installed it with and without sudo.

I wannet to mention that i have the same problem with face_recognition module.

@csparpa
Copy link
Owner

csparpa commented Sep 3, 2017

Same outcome also running pip3 show pyowm with sudo ?

Here my best guess is that your OSX actually has two Python3.6 interpreters along with their respective library folders, and modules get installed in different locations depending on the one you use. In your case, when you originally installed PyOWM with pip3, that was using an interpreter which was different than the one you ran when you after tried to import PyOWM.

This could be explained if you installed a new Python setup using Homebrew or similar package managers on OSX

Please run:

$ for b in `compgen -A command python3.6`; do     echo "Command: $b - $(which $b)"; done

and post back here, we should see the 2 binaries and their location.

Also these pages might be helpful to give you an idea of the issue (the 1st one also proposing a solution):

@BartzLeon
Copy link
Author

with sudo it says:

Name: pyowm
Version: 2.7.1
Summary: A Python wrapper around the OpenWeatherMap web API
Home-page: http://github.com/csparpa/pyowm
Author: Claudio Sparpaglione (@csparpa)
Author-email: csparpa@gmail.com
License: MIT
Location: /usr/local/lib/python3.6/site-packages
Requires:
The directory '/Users/leon/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

the command:

Command: python3.6 - /usr/local/bin/python3.6
Command: python3.6-32 - /usr/local/bin/python3.6-32
Command: python3.6-config - /usr/local/bin/python3.6-config
Command: python3.6m - /usr/local/bin/python3.6m
Command: python3.6m-config - /usr/local/bin/python3.6m-config
Command: python3.6 - /usr/local/bin/python3.6
Command: python3.6-32 - /usr/local/bin/python3.6-32
Command: python3.6-config - /usr/local/bin/python3.6-config
Command: python3.6m - /usr/local/bin/python3.6m
Command: python3.6m-config - /usr/local/bin/python3.6m-config
Command: python3.6 - /usr/local/bin/python3.6
Command: python3.6-32 - /usr/local/bin/python3.6-32
Command: python3.6-config - /usr/local/bin/python3.6-config
Command: python3.6m - /usr/local/bin/python3.6m
Command: python3.6m-config - /usr/local/bin/python3.6m-config
Command: python3.6 - /usr/local/bin/python3.6
Command: python3.6-32 - /usr/local/bin/python3.6-32
Command: python3.6-config - /usr/local/bin/python3.6-config
Command: python3.6m - /usr/local/bin/python3.6m
Command: python3.6m-config - /usr/local/bin/python3.6m-config
Command: python3.6 - /usr/local/bin/python3.6
Command: python3.6-32 - /usr/local/bin/python3.6-32
Command: python3.6-config - /usr/local/bin/python3.6-config
Command: python3.6m - /usr/local/bin/python3.6m
Command: python3.6m-config - /usr/local/bin/python3.6m-config

I habe installed python from the python website and with Homebrew .
Thanks for the answer.

@BartzLeon
Copy link
Author

One question can I just delete the python folder in my programs folder ore the version installed via Homebrew ?

@csparpa
Copy link
Owner

csparpa commented Sep 3, 2017

OK so now if you do:

$ /usr/local/bin/python3.6 -c 'import pyowm'
$ echo $?

you should see a 0 printed, which means the import went fine

@csparpa
Copy link
Owner

csparpa commented Sep 3, 2017

No, barely erasing that folder won't be enough... you need to uninstall that Python version using Homebrew itself

You can consider to keep the Homebrew-sourced Python installed and make a system-wide alias for it... I'm not a Mac user but you can check this out here or Google for it

@BartzLeon
Copy link
Author

/usr/local/bin/python3.6 -c 'import pyowm'

still says no module found named 'pyowm'

@csparpa
Copy link
Owner

csparpa commented Sep 3, 2017

OK, try again with sudo

If it doesn't work, then pip3 uninstall PyOWM and then it's up to you to either uninstall the Homebrew version and use the default MacOS or to alias the Homebrew version

@BartzLeon
Copy link
Author

BartzLeon commented Sep 3, 2017

Thanks it worked i did
brew uninstall python3
and then sudo pip3 install pyowm now i can import it.

Thanks a lot for your time.

@csparpa
Copy link
Owner

csparpa commented Sep 3, 2017

Super! You're welcome

@andrewlvovsky
Copy link

Was having the same issue, and a simple uninstall/reinstall of python through Homebrew worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants