Python Forum
No module named 'pysolar' - even tough pysolar is installed - What am I doing wrong?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
No module named 'pysolar' - even tough pysolar is installed - What am I doing wrong?
#1
Hello everyone :)
I have the following problem:

I have Python 3.8 installed and with anaconda3 i used the comand "pip3 install pysolar" to isntall pysolar (pysolar-0.9-py3-none-any.whl)

When i now type "import pysolar" in a python script and I run it as a module, then the following error shows up: "ModuleNotFoundError: No module named 'pysolar'".

I dont have a clue what I am doing wrong. I also didnt find an answer in the Internet. In the Internet its only written, that this error occurs, when pysolar is not installed. But i have it installed? When i go on anaconda3 again and type "pip3 install pysolar" I always get the message: "requirements already satisfied: pysolar in c:\users\xxx\anaconda3\lib\size-packages (0.9)" .

So that means, it should be installed correctly? Does anyone have a clue or could help me to get pysolar work please :)? Thank you very much for you help already.
Reply
#2
Make sure that (base) environment is active this is required in later version of Anaconda.
If using Anaconda Prompt it is automatically activated.

Here a quick run where i use cmder,so i activate myself has to same if just use cmd/poweshell.
G:\Anaconda3
λ cd Scripts\

# Activate, see that now show (base)
G:\Anaconda3\Scripts
λ activate

# Test pip,it will now always use pip form Anaconda
# If i deactivate it will use my Python 3.9 pip
(base) G:\Anaconda3
λ pip -V
pip 20.0.2 from G:\Anaconda3\lib\site-packages\pip (python 3.7)

# Install
(base) G:\Anaconda3
λ pip3 install pysolar
Collecting pysolar
  Downloading pysolar-0.9-py3-none-any.whl (46 kB)
     |████████████████████████████████| 46 kB 866 kB/s
Installing collected packages: pysolar
Successfully installed pysolar-0.9

# Test that it work
(base) G:\Anaconda3
λ python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysolar.solar import *
>>> import datetime
>>>
>>> latitude = 42.206
>>> longitude = -71.382
>>>
>>> date = datetime.datetime(2007, 2, 18, 15, 13, 1, 130320, tzinfo=datetime.timezone.utc)
>>> print(get_altitude(latitude, longitude, date))
30.914468243599078
So if using it from a Editor eg VS Code that i use will use code . to start from command line so it find environment automatically or can manually choice it in Editor.
Reply
#3
(May-08-2021, 04:01 PM)snippsat Wrote: Make sure that (base) environment is active this is required in later version of Anaconda.
If using Anaconda Prompt it is automatically activated.

Here a quick run where i use cmder,so i activate myself has to same if just use cmd/poweshell.
G:\Anaconda3
λ cd Scripts\

# Activate, see that now show (base)
G:\Anaconda3\Scripts
λ activate

# Test pip,it will now always use pip form Anaconda
# If i deactivate it will use my Python 3.9 pip
(base) G:\Anaconda3
λ pip -V
pip 20.0.2 from G:\Anaconda3\lib\site-packages\pip (python 3.7)

# Install
(base) G:\Anaconda3
λ pip3 install pysolar
Collecting pysolar
  Downloading pysolar-0.9-py3-none-any.whl (46 kB)
     |████████████████████████████████| 46 kB 866 kB/s
Installing collected packages: pysolar
Successfully installed pysolar-0.9

# Test that it work
(base) G:\Anaconda3
λ python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysolar.solar import *
>>> import datetime
>>>
>>> latitude = 42.206
>>> longitude = -71.382
>>>
>>> date = datetime.datetime(2007, 2, 18, 15, 13, 1, 130320, tzinfo=datetime.timezone.utc)
>>> print(get_altitude(latitude, longitude, date))
30.914468243599078
So if using it from a Editor eg VS Code that i use will use code . to start from command line so it find environment automatically or can manually choice it in Editor.


Thank you very much for your answer. As I had another problem with Anaconda, so I deinstalled it a couple of minutes ago. Is there a way to downlaod and use Pysolar with the normal Pyhton IDLE, without using anaconda or another program? If not, I will reinstall Anaconda and try the instructions you already wrote above.
Reply
#4
(May-08-2021, 02:39 PM)Jghurt Wrote: Hello everyone :)
I have the following problem:

I have Python 3.8 installed and with anaconda3 i used the comand "pip3 install pysolar" to isntall pysolar (pysolar-0.9-py3-none-any.whl)

When i now type "import pysolar" in a python script and I run it as a module, then the following error shows up: "ModuleNotFoundError: No module named 'pysolar'".

I dont have a clue what I am doing wrong. I also didnt find an answer in the Internet. In the Internet its only written, that this error occurs, when pysolar is not installed. But i have it installed? When i go on anaconda3 again and type "pip3 install pysolar" I always get the message: "requirements already satisfied: pysolar in c:\users\xxx\anaconda3\lib\size-packages (0.9)" .

So that means, it should be installed correctly? Does anyone have a clue or could help me to get pysolar work please :)? Thank you very much for you help already.

(May-08-2021, 04:01 PM)snippsat Wrote: Make sure that (base) environment is active this is required in later version of Anaconda.
If using Anaconda Prompt it is automatically activated.

Here a quick run where i use cmder,so i activate myself has to same if just use cmd/poweshell.
G:\Anaconda3
λ cd Scripts\

# Activate, see that now show (base)
G:\Anaconda3\Scripts
λ activate

# Test pip,it will now always use pip form Anaconda
# If i deactivate it will use my Python 3.9 pip
(base) G:\Anaconda3
λ pip -V
pip 20.0.2 from G:\Anaconda3\lib\site-packages\pip (python 3.7)

# Install
(base) G:\Anaconda3
λ pip3 install pysolar
Collecting pysolar
  Downloading pysolar-0.9-py3-none-any.whl (46 kB)
     |████████████████████████████████| 46 kB 866 kB/s
Installing collected packages: pysolar
Successfully installed pysolar-0.9

# Test that it work
(base) G:\Anaconda3
λ python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysolar.solar import *
>>> import datetime
>>>
>>> latitude = 42.206
>>> longitude = -71.382
>>>
>>> date = datetime.datetime(2007, 2, 18, 15, 13, 1, 130320, tzinfo=datetime.timezone.utc)
>>> print(get_altitude(latitude, longitude, date))
30.914468243599078
So if using it from a Editor eg VS Code that i use will use code . to start from command line so it find environment automatically or can manually choice it in Editor.

I did reinstall Anaconda to try your manual.

In the cmd it all "worked".
I got the following in the cmd:
Output:
>>> from pysolar.solar import * >>> import datetime >>> latitude =42.206 >>> longitude = 71.382 >>> date = datetime.datetime(2007, 2, 18, 15, 13,1, 130320,tzinfo=datetime.timezone.utc) >>> print(get_altitude(latitude, longitude, date)) -27.071838546599338
When I try that above written code in my normal python 3.8 IDLE i get the following error/output:
Error:
Warning (from warnings module): File "C:\Users\xxx\anaconda3\Lib\site-packages\numpy\__init__.py", line 138 from . import _distributor_init UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service -27.071838546599338
When i went to the link on github.com I did try to install the mkl service and it updated to a newer version. When i type it in Anaconda again to install the mkl service, i get the message, that all requested packages are installed. I still get the above shown error.

Output:
(base) C:\Users\xxx>conda install -c intel mkl-service Collecting package metadata (current_repodata.json): done Solving environment: done # All requested packages already installed.
Also another problem that occurs now, that didn't occured, when i did not have anaconda installed:

import pandas as pd
Import pandas was working before i installed anaconda. I did not get any errors before. Since installing Anaconda again, i get the following errors again:

Error:
Warning (from warnings module): File "C:\Users\xxx\anaconda3\Lib\site-packages\numpy\__init__.py", line 138 from . import _distributor_init UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service Traceback (most recent call last): File "C:\Users\xxx\Desktop\xxxx\xxxx\Test\xxxx\test1.py", line 1, in <module> import pandas as pd File "C:\Users\xxx\anaconda3\Lib\site-packages\pandas\__init__.py", line 16, in <module> raise ImportError( ImportError: Unable to import required dependencies: numpy: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE! Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed. We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubles ... error.html Please note and check the following: * The Python version is: Python3.8 from "C:\Users\xxx\AppData\Local\Programs\Python\Python38\pythonw.exe" * The NumPy version is: "1.19.2" and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help. Original error was: DLL load failed while importing _multiarray_umath: Das angegebene Modul wurde nicht gefunden.
Thats the reason, why I was asking, if there was another way to use Pysolar without using anaconda.. I am just getting problems here. Do you know a way to get Pysolar work with my normal IDLE ?

*Edit: After uninstalling Anaconda again, the "import pandas as pd" is working again. Still no clue, how to get Pysolar work :(
Reply
#5
(May-08-2021, 06:18 PM)Jghurt Wrote: Do you know a way to get Pysolar work with my normal IDLE ?
Yes it work with version from python.org,and IDLE i never use only new people use it for while as it's not good at all.
Want simple editor use Pyscripter or VS Cods evt Pychram for larger Editors.
Python 3.9/3.8 and pip installation under Windows.
VS Code from start.
# Test pip
C:\
λ pip -V
pip 21.1 from c:\python39\lib\site-packages\pip (python 3.9)

# Install
C:\
λ pip install pysolar
Collecting pysolar
  Using cached pysolar-0.9-py3-none-any.whl (46 kB)
Installing collected packages: pysolar
Successfully installed pysolar-0.9

# Test
C:\
λ python
Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec  7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pysolar.solar import *
>>> import datetime
>>>
>>> latitude = 42.206
>>> longitude = -71.382
>>>
>>> date = datetime.datetime(2007, 2, 18, 15, 13, 1, 130320, tzinfo=datetime.timezone.utc)
>>> print(get_altitude(latitude, longitude, date))
30.914468243599078
>>> exit()
Your error message show that you still mix stuff or (base) is not active.
It start point to Anaconda then later down.
* The Python version is: Python3.8 from "C:\Users\xxx\AppData\Local\Programs\Python\Python38\pythonw.exe"
Reply
#6
You are my king!! :) I think everything is working now. Thank you very very much! :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ModuleNotFoundError: No module named 'bluetooth' Error Rovelin 4 301 Aug-31-2021, 04:04 PM
Last Post: Rovelin
  ModuleNotFoundError: No module named 'graph' Anldra12 3 1,523 May-02-2021, 02:41 PM
Last Post: Anldra12
  ModuleNotFoundError: No module named 'fpdf' KatMac 4 1,808 Apr-19-2021, 01:23 PM
Last Post: KatMac
  ModuleNotFoundError: No module named 'com' aleksg 9 2,590 Dec-14-2020, 05:00 PM
Last Post: Larz60+
Video ModuleNotFoundError: No module named ‘…’ Frank911 1 1,472 Dec-11-2020, 03:59 PM
Last Post: michael1789
  no module named finbert found ErnestTBass 4 1,326 Dec-05-2020, 06:09 PM
Last Post: andrianas
  ModuleNotFoundError: No module named 'fcntl' ErnestTBass 2 6,393 Dec-05-2020, 02:39 PM
Last Post: ErnestTBass
  ImportError: No module named coltson 3 1,136 Nov-21-2020, 10:22 AM
Last Post: Superjoe
  ModuleNotFoundError: No module named 'pyrlang.gen_server' Maxximiliann 0 669 Nov-19-2020, 01:15 AM
Last Post: Maxximiliann
  ModuleNotFoundError: No module named 'requests' Martin 2 1,000 Oct-04-2020, 03:35 PM
Last Post: Martin

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020