[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pysolar-discuss] Installation possible issue: Downloads Pysolar to wrong directory?


That's awesome. I'm glad to see Pysolar used for real stuff.

Just for the sake of history, if you do ever need to install a version of
Pysolar for Python 2, you can do it like this: sudo pip install -I
pysolar==0.6

Brandon

On Sat, Aug 8, 2015 at 2:32 PM, Jay Doscher <jay@xxxxxxxxxxxxx> wrote:

> Thanks- I am still using an older release and Python2, which is working OK
> for me now.  I will be updating my code soon for a newer project, but
> here's what I have that works fine for me.
>
> def getsolarangle():
>         solarangle = Pysolar.GetAltitude(maplat, maplon,
> datetime.datetime.utcnow())
>         return solarangle
>
>
> The code is in active use today, and the robot I am using it for can be
> found here:
> https://twitter.com/SolarRobot7
>
> Thanks,
> Jay
>
> On Sat, Aug 8, 2015 at 11:26 AM, Brandon Stafford <brandon@xxxxxxxxxxxxxxx
> > wrote:
>
>> Hi Ryan and Jay,
>>
>> This reply is a couple of months late, but maybe it will help future
>> users.
>>
>> To install Pysolar, you need to use pip3 rather than pip. Otherwise, it
>> gets installed for Python 2, which doesn't work, and Python 3 can't find
>> it. (When you ran into trouble, the installation instructions on
>> http://pysolar.org were wrong. I just updated them.)
>>
>> Anyway, the proper installation command is: sudo pip3 install pysolar
>>
>> If you run into the error: "AttributeError: 'datetime.datetime' object
>> has no attribute 'timestamp'", it is very likely that you are using a new
>> version of Pysolar (newer than 0.6) that only works with Python 3. The
>> fundamental problem here is that Python 3's datetime module can produce
>> Unix timestamps natively, but Python 2's version can't. This is one of the
>> reasons (maybe the only reason?) that Pysolar needs Python 3.
>>
>> If someone wanted to make Pysolar work with Python 2 again, the first
>> step would be to figure out how to generate timestamps properly. You might
>> start here:
>> http://stackoverflow.com/questions/19801727/convert-datetime-to-unix-timestamp-and-convert-it-back-in-python
>>
>> Cheers,
>> Brandon
>>
>> On Fri, Jun 12, 2015 at 6:08 PM, Jay Doscher <jay@xxxxxxxxxxxxx> wrote:
>>
>>> I'm running pysolar under 2.4, but I use this wording:
>>>
>>> import Pysolar
>>>
>>> My guess is that "Pysolar" is case sensitive.  Hope this helps,
>>>
>>> Jay
>>>
>>> On Thu, Jun 4, 2015 at 3:26 PM, Ryan Kapur <ryankapur@xxxxxxxxxxxx>
>>> wrote:
>>>
>>>> I installed pysolar via "sudo pip install pysolar" and I have
>>>> python3.4.2 on my 64-bit Ubuntu machine.
>>>>
>>>> Following along to the documentation, when I'm in python and I try:
>>>>  *>>>from pysolar.solar import **
>>>>  ImportError: No module named 'pysolar.solar'
>>>>
>>>> Pysolar automatically downloaded to
>>>> /usr/local/lib/python2.7/dist-packages/pysolar
>>>>
>>>>
>>>> ......................................................................................................
>>>>
>>>> To reiterate:
>>>> When I ran python3 myprogram.py I get:
>>>>
>>>> *    from pysolar.solar import *ImportError: No module named
>>>> 'pysolar.solar'*
>>>>
>>>> When I run python myprogram.py I get:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *Traceback (most recent call last):  File "tracker.py", line 22, in
>>>> <module>    get_altitude(42.206, -71.382, d)  File
>>>> "/home/ryankapur/.local/lib/python2.7/site-packages/pysolar/solar.py", line
>>>> 58, in get_altitude    jd = time.get_julian_solar_day(when)  File
>>>> "/home/ryankapur/.local/lib/python2.7/site-packages/pysolar/time.py", line
>>>> 742, in get_julian_solar_day    +AttributeError: 'datetime.datetime' object
>>>> has no attribute 'timestamp'*
>>>>
>>>>
>>>> .......................................................................................................
>>>>
>>>> Why did Pysolar automatically download to the 2.7 directory? I moved it
>>>> to the 3.4/dist_packages manually with nautilus but* it didn't work*.
>>>> It only worked when I repeated this process after cloning the git
>>>> repository.
>>>>
>>>> I hope this long message can provide some useful feedback because it
>>>> was frustrating for me to figure out these import module errors--want to
>>>> make sure others don't encounter this in the future. Cheers to Pysolar!
>>>>
>>>>
>>>> Regards,
>>>> Ryan
>>>>
>>>
>>>
>>
>>
>> --
>> Brandon Stafford
>> Rascal Micro: small computers for art and science
>> Somerville, MA, USA
>>
>
>


-- 
Brandon Stafford
Rascal Micro: small computers for art and science
Somerville, MA, USA