首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PythonAnywhere -没有名为'pyvirtualdisplay‘的模块

PythonAnywhere -没有名为'pyvirtualdisplay‘的模块
EN

Stack Overflow用户
提问于 2017-11-02 23:36:08
回答 1查看 3.2K关注 0票数 1

我正在尝试在PythonAnywhere上运行一个在线项目。当我调用这个函数时:

代码语言:javascript
复制
def getPrice(item_url):
    from forex_python.converter import  CurrencyRates
    from selenium import webdriver
    from pyvirtualdisplay import Display
    #from IPython.display import display
    with Display():
        browser = webdriver.Firefox()
    try:
        browser.get(item_url)
        item_price = browser.find_element_by_xpath("//SPAN[@class='market_table_value normal_price']").text
        #item_price isn't an integer, it's a string, 'Prezzo iniziale: $' and 'USD' need to be cut with .replace, then converted to int with int()
        #item_price_edited is the int() variable, ready to be used
        #price is the final value, ready for use
        item_price_cut1 = item_price.replace('Prezzo iniziale','')
        item_price_cut2 = item_price_cut1.replace('$','')
        item_price_cut3 = item_price_cut2.replace('USD','')
        item_price_edited_usd = float(item_price_cut3)
        #the value of the price is USD, it needs to be converted to EUR
        c = CurrencyRates()
        #round arrotonda il valore con la virgola a due numeri decimali
        price = round(c.convert('USD','EUR', item_price_edited_usd),2)
        browser.close()
        return price
    finally:
        browser.quit()

我得到了这个错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "/home/BobbyQ/mm/check.py", line 13, in <module>
    price = getPrice(item_url)
  File "/home/BobbyQ/mm/functions.py", line 6, in getPrice
    from pyvirtualdisplay import Display
ModuleNotFoundError: No module named 'pyvirtualdisplay'

所以我应该安装这个模块,但是当我运行:

代码语言:javascript
复制
pip install pyvirtualdisplay

我明白了:

代码语言:javascript
复制
Requirement already satisfied (use --upgrade to upgrade): pyvirtualdisplay in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied (use --upgrade to upgrade): EasyProcess in /usr/local/lib/python2.7/dist-packages (from pyvirtualdisplay)

所以模块应该已经安装了,但是当我尝试导入它时,我得到了第一个error...How,我能解决这个问题吗?

EN

回答 1

Stack Overflow用户

发布于 2019-11-27 20:31:41

只需转到web选项卡并找到Virtualenv设置,然后回到web选项卡本身,在virtualenv部分中编辑到您的Virtualenv的路径。您可以指定完整路径/home/myusername/.virtualenvs/myproject,或者仅指定virtualenv的短名称myproject,在您提交后,系统会自动将其展开为完整路径。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47079146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档