Import error: Cannot import name linkedin

Hy there,

I am new here and just tried to make a scheduled task, which resulted in the error from the title.

  • On my computer the script is running
  • I installed the module linkedin with pip3.6
  • When googling I found a lot about circular dependencies - not the case here I guess

Here is the code:

from linkedin import linkedin
import time
from bs4 import BeautifulSoup
from urllib import request

application = linkedin.LinkedInApplication(token=TOKEN_PAUL)
date_today = time.strftime("%d.%m.%Y")

link_to_share = "" 
html = request.urlopen(link_to_share).read().decode('utf8')
soup = BeautifulSoup(html, 'html.parser')
title = soup.find('title')

print(application.submit_share(comment=None, title=title.string, description=None, submitted_url=link_to_share))

Perhaps anyone can help? Thank you.

Edit: The file was created on Windows. Do I have to use dos2unix or something similar? Had this issue in the past on another server

I could fix the problem by manually uploading the files to home/username/python3.6/site-packages.

Now another problems appears:

html = request.urlopen(link_to_share).read().decode('utf8')

leads to: urllib.error.HTTPError: HTTP Error 999: Request denied

This code also works at other places, are the restrictions from pythonanywhere or some other tip that could help solving the problem?

That seems to be a response from the service you're accessing. The body of the response may have more detail.

Thank you, you are right this only affects certain sites. Most sites are working fine.

It's possible that those sites are just blocking incoming requests from cloud services -- some sites do, especially if you're doing web scraping.

Oh, one other thing, regarding the "linkedin" module -- if you're using Python 3.6, you should install the module on PythonAnywhere using the "pip3.6" command. See this help page for details.