I'm working with MacOS, I've installed Python and iPython, but when I type:
import nltk
ipython tells me that there is no module named nltk. However, when I type in:
import sys
import nltk
It works perfectly fine. Can someone explain why this isn't working correctly? I'm a newbie to Python so please be gentle. Thanks.
Related
I'm getting an ImportError attempting to run a Locust/Selenium script: ImportError: cannot import name 'StopLocust' from 'locust.exception'
Is there a package that I need to install?
from realbrowserlocusts import ChromeLocust
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from locust_plugins.users import WebdriverUser
from locust.exception import StopLocust
import os
from locust import TaskSet, task
The output from the Terminal window shows this:
File "c:\users\mjohns33\pycharmprojects\omni\lib\site-packages\realbrowserlocusts\core.py", line 6, in
from locust.exception import StopLocust
ImportError: cannot import name 'StopLocust' from 'locust.exception' (c:\users\mjohns33\pycharmprojects\omni\lib\site-packages\locust\exception.py)
Any ideas?
If you're using Locust 1.0+ there is no StopLocust in locust.exceptions. I'm not sure what it is you're looking to do so I don't know if it's the right thing for you to use, but there is StopUser in there that you should be able to import.
Local environment issue. Re-installing my setup.
After doing some more research I was able to resolve a couple of issues from the import error. Installing locustio solved the import issue and a follow-on issue in attempting to load the locust web page was solved by updating gevent.
So, for the full fix uninstall the current version of locust and install the locustio version. Then upgrade the gevent.
pip uninstall locust
pip install locustio==0.14.6
pip install --upgrade gevent
Realbrowserlocusts isn't compatible with the most recent versions of Locust. Downgrading to version locust 0.13.5 fixed the issue. I'm not sure exactly which of the most recent versions of locust supports realbrowserlocusts. I would like to find out though so I'm running the best of locust versions supporting running with selenium.
I'm using the Python pillow module, but every time I try to import it and use a function, it gives me an error. Here is some code to reproduce the error.
import PIL
PIL.ImageGrab.grab()
You have to use from to import from PIL.
from PIL import ImageGrab
ImageGrab.grab()
I've a local function to transform my data on a local.
For example, when I tried to import:
import com.company.area.project.area.functions
I've received the error:
console: 49: error: object company is not a member of package com
import com.company.area.project.area.functions
I'm using Anaconda and the pip. Reading trough the web I've found this question: Is there a pip / easy_install for Scala?
So, I noticed that there is no a equivalent to "Pip install ." we have in python.
So, the question is. How can I import a custom function in my Jupyter Notebook?
First you have to ensure that you have Scala environment enabled for your jupyter notebook.
pixiedust can help you with installing scala packages in your jupyter notebook.
A specific example in your case will be to deploy your project as a jar file to a repository or an address where you can then pass to the pixiedust package
Code example should look like this:
import pixiedust
pixiedust.installPackage("https://github.com/companyrepo/jars/raw/master/dist/functions-assembly-1.0.jar")
I did conda install for numpy, pandas, scipy, and scikit-learn apparently all successful. I also tried to change the path in the Windows 10 registry. I only have 1 version of Python, 3.6 installed. I also installed Visual Studio. If I run the script, I get "scipy module not found". Can you explain me what's the problem, and how to fix this?
My imports look like this:
import pandas as pd
import quandl, math
import numpy as np
from sklearn import preprocessing, cross_validation, svm
from sklearn.linear_model import LinearRegression
I'm following this tutorial by Sentdex:
https://www.youtube.com/watch?v=r4mwkS2T9aI&index=4&list=PLQVvvaa0QuDfKTOs3Keq_kaG2P55YRn5v
from sklearn.linear_modelsklearn._model import SGDClassifierNo module named linear_modelsklearn._model
I am on OSX version 10.9.4
Python 2.7.6
numpy 1.9.0
scipy 0.14.0
scikit-learn 0.15.2 What I am missing? Thanks.(import sklearn works fine but not the model)
Your import seems wrong, try:
from sklearn.linear_model import SGDClassifier