I am a beginner with python, I am working on this project using a module named classy-classification. I pip-installed it and checked if it was actually correctly installed where it should be, and tried to install it manually, but I am still getting the same ModuleNotFoundError error.
import spacy
import classy_classification
data = {
"furniture": ["This text is about chairs.",
"Couches, benches and televisions.",
"I really need to get a new sofa."],
"kitchen": ["There also exist things like fridges.",
"I hope to be getting a new stove today.",
"Do you also have some ovens."]
}
nlp = spacy.load("en_core_web_md")
nlp.add_pipe(
"text_categorizer",
config={
"data": data,
"model": "spacy"
}
)
print(nlp("I am looking for kitchen appliances.")._.cats)
The error:
C:\Users\BC\PycharmProjects\pythonai\venv\Scripts\python.exe C:/Users/BC/PycharmProjects/pythonai/main.py
Traceback (most recent call last):
File "C:\Users\BC\PycharmProjects\pythonai\main.py", line 2, in <module>
import classy_classification
ModuleNotFoundError: No module named 'classy_classification'
Process finished with exit code 1
Sometimes, if you have multiple versions of Python installed and/or multiple environments, it can be a bit tricky to install packages. It looks like your code is running using the Python interpreter located at C:\Users\BC\PycharmProjects\pythonai\venv\Scripts\python.exe.
So, try using the following command to install classy_classification: C:\Users\BC\PycharmProjects\pythonai\venv\Scripts\python.exe -m pip install classy_classification.
In general, instead of running pip [args], you can run /path/to/python -m pip [args] to specify the Python version/interpreter that pip installs packages for.
Related
I have recently been asked to learn the AWS-CDK module in Python to handle deployments and following the examples on in the AWS-CDK documentation I am getting an error that indicates it cannot import 'core'
I have created a virtual environment that is using Python 3.6.6 and am running CDK version 1.16.2 (build 5893301) all running on a Windows 10 64-bit machine in VSCode
from aws_cdk import core
I would expect this to just load the constructor but it just returns the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'core'
I have searched and searched and I cannot seem to find what I am doing wrong or anything that contradicts the documentation on the CDK site. Any insight would be appreciated.
This worked for me. Might be related to conda / venv interactions.
pip3 install -r requirements.txt --user
Is aws_cdk.core installed in your environment?
I have this:
pip list|grep core
aws-cdk.core 1.68.0
I noticed that the cdk.json "app" value can also generate this error.
Example of the cdk.json file which used to generate the error:
{
"app": "python3 app.py",
"context": {
...
}
}
Changing the app value from python3 to python resolved the problem for me. Like this:
{
"app": "python app.py",
"context": {
...
}
}
I am not entirely sure why this happens as I am using python 3.8 and I can see a python.exe in the python path/environment variables. If I deactivate the virtual env, and I have cdk installed globally, this problem goes away regardless of whether I use python or python3 for the app value. Therefore, I suspect it's got to do something with environment paths.
aws-cdk-lib==2.34.0
constructs>=10.0.0,<11.0.0
aws-cdk.aws-kinesisfirehose-alpha
aws_cdk.aws-kinesisfirehose-destinations-alpha
aws_cdk.core
pip list|grep core
If you are unable to load this module that means it is not installed. It is possible that it is not installed in the python virtual environment you are using. When I search aws_cdk module in my working directory using find . -name aws_cdk , I found that I had two virtual environments setup. One was under venv and other one was .venv. And the module installed were installed in one of them but not in the other environment. Switching the environment and installing the module fixed the error.
I am having trouble installing a custom python module I have written.
Here are my steps so far:
Navigate to the module directory C:\Users\myname\repos\mymodulename where the setup.py file is in the anaconda prompt. Type: python setup.py install
The command prompt returns (plus some other things)
Extracting mymodulename-0.1-py3.7.egg to c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages
mymodulename 0.1 is already the active version in easy-install.pth
Installing myclass-script.py script to C:\Users\myname\AppData\Local\Continuum\anaconda3\Scripts
Installing myclass.exe script to C:\Users\myname\AppData\Local\Continuum\anaconda3\Scripts
Installed c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages\mymodulename-0.1-py3.7.egg
Processing dependencies for mymodulename==0.1
...
Using c:\users\myname\appdata\local\continuum\anaconda3\lib\site-packages
Finished processing dependencies for mymodulename==0.1
To me that looks like it has installed. Opening up the console and trying to import:
>>> import mymodulename.myclassas ce
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mymodulename'
>>>
It appears in hasn't. Checking the list of modules in anaconda with help('modules') confirms that it has not been imported.
I thought that perhaps i had installed it to the wrong environment:
(base) C:\Users\myname>conda env list
# conda environments:
#
base * C:\Users\myname\AppData\Local\Continuum\anaconda3
py2 C:\Users\myname\AppData\Local\Continuum\anaconda3\envs\py2
Only a python 2 environment which mymodule wouldn't be compatible with.
Does anyone have any suggestions about what I can try to resolve this? Happy to elaborate on any of the points
Thanks in advance.
EDIT: Some more information that may be relevant.
This package was initially installed in site-packages. I have reinstalled there and the package works. The reason I moved the package is because I am aware it is bad practice to store custom packages there.
When I was trying to import modules like "pymc3" or "theano", the rPython or PythoninR are not able to locate these modules even though I have already installed them. I am using Ubuntu 16.04, R 3.4.2, and python 3.5.2
It seems like these two packages fail to locate a certain folder, but it doesn't work after I append the path into sys.path, which contains all the packages I need, by using this command:
pyExec("sys.path.append('/home/lijiakai/.local/lib/python3.5/site-packages')")
Result also seems like good:
pyExec('import sys; print(sys.path)')
['', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-x86_64-linux-gnu', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages', '.', '/home/lijiakai/.local/lib/python3.5/site-packages']
I imported the packages:
pyExec('import pymc3')
Then received the following errors:
Traceback (most recent call last): File "<string>", line 1, in
<module> **ImportError** : No module named 'pymc3' Error in
pyExec("import pymc3") : An error has occured while executing
Python code. See traceback above.
Totally got me crazy ... really appreciate if anyone can help me out here.
Thanks
If you use anaconda, you might want to turn to turn to the package reticulate, where you can specify the python version to use.
# install.packages("reticulate")
library(reticulate)
use_python("/anaconda/bin/python")
However, from my experience this is slower.
Otherwise, if you use 'standard' Python, you can start by removing rPython:
remove.packages("rPython")
And then re-install it specifying the version:
install.packages("rPython", configure.vars= "RPYTHON_PYTHON_VERSION=3.5")
This should then use Python_3.5 on your machine, see here for more details.
You can test, if it was successful by using:
library(rPython)
python.exec(c("import sys", "\n", "print(sys.version)"))
I am a noob with installing python programs. I know there are a lot of Questions like this here, I have tried to find a solution for my problem but I can't fix it.
First of all, I am trying to install a program called Qarq. The readme says:
Setup
In order to get qark running, it must be present on your python path. If not, it may lead to module not found errors. This can be done for your current shell by running the following:
export PYTHONPATH={qark root directory}:$PYTHONPATH
Well, I type the command. I check the variable with an echo and I can see the directory in the variable. However, I type "python setup.py install" and I get this error:
santoku#santoku-PC:~/qark$ python setup.py install
Traceback (most recent call last):
File "setup.py", line 1, in <module>
from setuptools import setup, find_packages
ImportError: No module named setuptools
Then, I read in a question here that you must install setuptools, so I did it. I ran the next command:
sudo apt-get install python-setuptools
But the problem is still there, I try to run "python setup.py install" and I get the same error.
On the other hand, the readme says you only need to execute "$ python qarkMain.py". I do that and I get the same error with different module:
santoku#santoku-PC:~/qark/qark$ python qarkMain.py install
Traceback (most recent call last):
File "qarkMain.py", line 30, in <module>
from qark.modules.IssueType import IssueSeverity
ImportError: No module named qark.modules.IssueType
I am using Python 2.7.12 (default, Nov 12 2016, 01:02:22) [GCC 4.8.4] on linux2. (Ubuntu 14.04.5 LTS)
I have tried to install qark on Ubuntu 16.04.1 LTS and it worked perfectly. I didn't need to install setuptools. Both have the same python version.
I guess the problem is python can't find the modules, maybe I have to move the qark directory to another directory.
I think that's all, if you need more extra information just ask me.
I need your help, I am sure my problem is a foolishness and easy to fix. But I am a noob with python and I don't have any idea.
Thank you very much and thanks in advance.
Sorry for my English, I am not a native speaker.
EDIT: I found a solution, I tried to install again the OS and now python works properly, I don't know if I broke python or I did something bad. Anyway, Thanks.
i could get it work typing this:
1) PYTHONPATH=\home\santoku\qark\qark\:$PYTHONPATH
then just type:
2) python qarkMain.py
I am learning Constraint Programming in Python and, for the solving of the problems, I am supposed to use the SCIP solver. I have installed the Numberjack standard package from Github witch includes Mistral, Mistral2, Toulbar2, MipWrapper, SatWrapper, MiniSat and Walksat solvers.
Running my code I got the following error:
Traceback (most recent call last):
File "/Users/angelocoelho/anaconda3/lib/python3.5/site-packages/Numberjack/__init__.py", line 910, in load
lib = __import__(solverstring, fromlist=[solverspkg])
ImportError: No module named 'Numberjack.solvers.SCIP'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "grafosdefluxos.py", line 42, in <module>
solver = model.load('SCIP')
File "/Users/angelocoelho/anaconda3/lib/python3.5/site-packages/Numberjack/__init__.py", line 915, in load
solvername)
ImportError: ERROR: Failed during import, wrong module name? (SCIP)
I already ran make in 'scipoptsuite-3.1.0' and in 'scip-3.2.1', installed Numberjack-master's 'setup.py' and tried this:
python setup.py -solver SCIP
witch returned the error
Error: the solver 'SCIP' is not known, please use one of: Mistral, SatWrapper, Toulbar2, Walksat, MipWrapper, MiniSat, Mistral2
I have the SCIP folders alongside and inside the Numberjack folders.
I read and ran all the commands in the README and INSTALL files on how I could get this solver configured but I couldn't get it right.
How can I get SCIP available to solve the problems in Numberjack?
After talking to the assistant teacher I got the answer for this problem.
The folder where Numberjack/SCIP was being installed was not the one it was supposed to be, therefore it was not really included in the solver list. After completing the python setup.py build and python setup.py install installation I ran python setup.py build -solver SCIP and the terminal feedback stated
Successfully built solver interfaces for MipWrapper, SCIP
But the jupyter notebook didn't recognize the solver.
What solution should work having Anaconda (python3.5) already installed:
Download Numberjack (file "Numberjack-master.zip") and unpack it.
Download SCIP and copy the downloaded file, scipoptsuite-3.1.0.tgz. Paste it inside Numberjack-master unpacked directory. The path of it should be ~/Downloads/Numberjack-master/scipoptsuite-3.1.0.tgz.
In terminal run cd ~/Downloads/Numberjack-master (or your Numberjack-master directory path).
Then run python3.5 setup.py install --user.
In my case Jupyter was looking for the solvers in
~/anaconda3/lib/python3.5/site-packages/Numberjack/ and they were
not being installed there so, instead of using python, I used python3.5 since my Anaconda was the Python 3.5 package.
Why is there a scip-3.2.1 directory? The SCIP Opt Suite 3.1.0 contains SCIP 3.1.0. You need to make sure to run all setup and make commands exactly as stated on the Numberjack install page.