I created a project in Pycharm including a gp.py, copied the project folder to another machine and tried to run the gp.py script from command line using python gp.py. However I got a error
Traceback (most recent call last):
File "gp.py", line 2, in <module>
from gplearn.genetic import SymbolicRegressor
ModuleNotFoundError: No module named 'gplearn'
The thing is I could see this gplearn library I used in the project folder, like below. The screen shot is not from Pycharm but the folder I copied to another computer. I tried to place the gp.pyinside and outside venv folder but neither worked. Could you please help to point out what the problem is ? Many thanks
gplearn package is not installed in the new machine.
Go to cmd prompt/terminal in pycharm and execute below line:
pip install gplearn
Sound like you are seeking for a method to deploy your script to end user, in this case maybe you can give Pyinstaller a try.
Related
I am new to python and trying to run code from existing project. I am getting the below error:
Traceback (most recent call last):
File "/xxxx/xxxx/Library/Application Support/JetBrains/IdeaIC2021.1/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py", line 2, in <module>
import pytest
ModuleNotFoundError: No module named 'pytest'
The file is present in the mentioned path.
I see that there are many questions regarding this but nothing seems to provide me with a solution.
I am using the IntelliJ IDEA IDE.
The error message is telling you that File "/xxxx/xxxx/Library/Application Support/JetBrains/IdeaIC2021.1/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py" is trying to import pytest but fails to find the package. That is, it's not the presence of that file that's failing, but that it can't find pytest in order to import it.
Install pytest using
python3 -m pip install pytest
Change python3 accordingly to use the specific installation of python that you're using in the IDE.
This is because you don't have the needed environment.
Since you use the Pycharm, you can try to install pytest.
https://blog.finxter.com/how-to-install-a-library-on-pycharm/
This worked for me. Repeating here:
Open IntelliJ's settings/preferences
Go to Tools -> Python Integrated Tools
Under Testing...Default test runner: choose pytest
Click the Fix button that appears in the bottom of the panel
I am working on a project to extract text from a bunch of scanned PDF's. I am following this tutorial. One of the first steps involves importing modules. I'm having some trouble importing 'pdf2image'. For context, I'm using a Conda environment called, "textExtractor" in VS Code's Python terminal. I checked if pdf2image was installed by running "Conda list" and it looks to be installed. However, when I run the python script I get an error saying,
(textExtractor)
C:\Users\mhiebing\Documents\GitHub_Repos\MonthlyStatsExtract>C:/Users/mhiebing/Anaconda3/python.exe
c:/Users/mhiebing/Documents/GitHub_Repos/MonthlyStatsExtract/PDF_to_Image.py
Traceback (most recent call last): File
"c:/Users/mhiebing/Documents/GitHub_Repos/MonthlyStatsExtract/PDF_to_Image.py",
line 1, in
from pdf2image import convert_from_path, convert_from_bytes
ModuleNotFoundError: No module named 'pdf2image'
Below is a screenshot showing pdf2image and the error:
Any idea what's going wrong?
The python interpreter you selected is not the textExtractor but the mhiebing.
You can click the Status Bar of interpreter to switch the interpreter. And you can refer to the official docs for more details.
It looks like you type the command to run the file, it's not recommended. You can click the green triangle button on the top right corner or the F5 to debug it. If you do that you can find out the truthly environment you are taking.
All of my project files in VS code suddenly gives an error saying that it cannot import modules (even tho the modules are local i.e same directory and they used to work pretty well before).
The code works fine in pycharm but not in VS code, any idea whats going on?
Code:
from backend.util.crypto_hash import crypto_hash
from backend.config import MINE_RATE
error:
env DEBUGPY_LAUNCHER_PORT=34625 /home/nikhil/python-blockchain/blockchain-env/bin/python /home/nikhil/.vscode/extensions/ms-python.python-2020.3.71659/pythonFiles/lib/python/debugpy/no_wheels/debugpy/launcher /home/nikhil/python-blockchain/backend/app/__init__.py
Traceback (most recent call last):
File "/home/nikhil/python-blockchain/backend/app/__init__.py", line 2, in <module>
from backend.blockchain.blockchain import Blockchain
ModuleNotFoundError: No module named 'backend'
Close VS Code,
start it again, Go to File > open folder (open your project folder in vs code),
if it gives a prompt to select a existing virtual environment, select that.
Then you should be good to go.
More unrelated information:
I assume the issue here is that there's some problem with VS Code not recognizing the virtual environment properly. This has happened to me several times and I cannot point out why that happens. But the above solution is a quick fix and always works for me.
I'm not sure if this will resolve OP's (ten-month old) question, but I've been struggling with the same error using debugpy while trying to configure VSCode's debugger.
Step 4 of this resource resolved the issue for me. In particular, I was using the -m flag when running debugpy, but the module to be run was not in the current working directory. Once I had changed this, the debugger worked as expected. As an example, if the command was originally:
python -m debugpy --listen 0.0.0.0:5678 ./some/directory/my_script.py
then the following two commands would rectify it:
cd ./some/directory
python -m debugpy --listen 0.0.0.0:5678 ./my_script.py
After doing this, I no longer received the "No module found" error.
The main reason is that VSCode does not automatically configure environment variables for you, but PyCharm does. The simplest method is adding your module file to system path.
import sys
sys.path.append(module_file_path)
The better solution is to config your environmental path named PYTHONPATH, adding related module path to it, and after that you will no longer need import system path manually.
Hope it works!
I'm not too familiar with mac, but I fired up pycharm to run a script I made that uses the zenpy module. Problem is when I try to execute it, I get the error
Error Message:
Traceback (most recent call last):
File "/Users/thisisfake/PycharmProjects/untitled1/venv/bin/test.py", line 29, in <module>
from zenpy import Zenpy
ModuleNotFoundError: No module named 'zenpy'
The obvious answer is, oh, I forgot to add the module to zenpy. So I went to File -> Preferences for New Projects -> Project Interpreter and added zenpy. Tried the script again, no dice. Check the project interpreter and zenpy is definitely there. I tried creating a new project entirely and re-adding it that way and no success. Tried moving the script to the bin folder, no luck. Added zenpy via pip in terminal, same result. I'm definitely missing something obvious, any idea what it is?
Thanks!
Select View -> Tool Windows -> Terminal
pip install zenpy
I am unable run interpreter in Eclipse. I made a new interpreter which is loading python2.7 from the Virtual environment.
When i run the manage.py file it is giving me error, as it is unable to load the module.
It works fine if I am executing it from terminal, but it gives me error when i run the command from eclipse.
Error:
Traceback (most recent call last):
File "/home/workspace/tms/manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
Am i facing this problem because of Ubuntu 11.0, or is there some other problem ?
Can anyone pls help me..
It sounds like your interpreter isn't properly set up. I would suggest configuring a new one. When you select the location of your new interpreter make sure you use the python executable from within your virtualenv (not the system one), that's probably /path/to/your/virtualenv/bin/python.
When you get to the point where eclipse invites you to add folders to your python path, it's proably easiest just to click 'select all'. This should include all the packages (eg django) from your virtual env.
Then use this new interpreter on your project and eclipse should be able to find the django.core.management module (and all the other modules used in your project).