unable to run interpreter in eclipse - python

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).

Related

Pycharm: DLL load failed: The specified procedure could not be found

I am working on a Python project in Pycharm (2020.1.2) on Windows 10.
For this project, I cannot use the standard Python interpreter, I have to use my own located at C:\some\path\here\python\27_64\python.exe (Python 2.7.3).
Backstory may be important:
I have added this path to the system path for both myself and all users, and placed it ahead of %LOCALAPPDATA%\Microsoft\WindowsApps to try to prevent the Microsoft store from popping up whenever I try to run python on the command line - however I don't feel like this change to the path variable has made a difference, as the Microsoft store still pops up.
I can start a Python shell by running C:\some\path\here\python\27_64\python.exe, so I know it technically works. When I do so; the sys.path is as follows:
['', 'C:\\another_place\\Python_2.7.3_x64\\python27.zip',
'C:\\some\\path\\here\\python\\27_64\\DLLs',
'C:\\some\\path\\here\\python\\27_64\\lib',
'C:\\some\\path\\here\\python\\27_64\\lib\\plat-win',
'C:\\some\\path\\here\\python\\27_64\\lib\\lib-tk',
'C:\\some\\path\\here\\python\\27_64',
'C:\\some\\path\\here\\python\\27_64\\lib\\site-packages']
Anyway, when I try to run a Python console (not even my script), this is the message I get in Pycharm:
C:\some\path\here\python\27_64\python.exe "C:\Program Files\JetBrains\PyCharm 2020.1.1\plugins\python\helpers\pydev\pydevconsole.py" --mode=client --port=59771
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2020.1.1\plugins\python\helpers\pydev\pydevconsole.py", line 5, in <module>
from _pydev_comm.pydev_rpc import make_rpc_client, start_rpc_server, start_rpc_server_and_make_client
File "C:\Program Files\JetBrains\PyCharm 2020.1.1\plugins\python\helpers\pydev\_pydev_comm\pydev_rpc.py", line 1, in <module>
import socket
File "C:\some\path\here\python\27_64\lib\socket.py", line 47, in <module>
import _socket
ImportError: DLL load failed: The specified procedure could not be found.
Process finished with exit code 1
I have gone to Settings>Project:[name]>Project Interpreter and set it to C:\some\path\here\python\27_64\python.exe (and rebooted Pycharm to be sure). That said; in the settings window no packages are shown and it claims that Python packaging tools can not be found.
When I click the link to install them (circled in red), they can not be installed due to this error:
ImportError: cannot import name _remove_dead_weakref
Are there other variables or settings I need to change?
Thanks
EDIT
Uninstalling the first Python on my Path (C:\\another_place\\Python_2.7.3_x64\\python27.zip) just makes everything so much worse
EDIT 2
I added the PATH variable manually to both the Python console settings and to the Run/Debug settings in PyCharm (and restarted the program), the result is still the same
I had a similar issue. This procedure fixed my issue.
Try the following:
run print(os.environ['PATH']) in the system terminal using the same interpreter
copy the result and add as PATH environment variable to your Run/Debug Configuration
do the same for Python Console settings
I hope it will work.
It seems that the interpreter is not being recognized by the windows as a result of which you are unable to install packages.
Also, I suppose the interpreter should be present in the bin folder of your python folder. The interpreter does not have a .exe extension.
I would suggest installing anaconda python 2.7 64 Bit windows package installer and using the condo environment and work on python 2.7
Here is a link I found for Python 2.7 on Windows hope this helps:
https://docs.python.org/2/faq/windows.html
Had the similar issue, in my case it was always trying to find libraries in PostgreSQL installation directory.
Mentioning sys.path helped me here! I tried printing it from inside my script and realized that PostgreSQL directories appear earlier in the list than Python directories.
SO, how I finally fixed it -- added PYTHONPATH environment variable to my Run configuration in PyCharm like this (replace with paths to your Python installation directory):
PYTHONPATH=D:\PROGRAMS\Python\Python3.9\DLLs\;D:\PROGRAMS\Python\Python3.9\lib\;D:\PROGRAMS\Python\Python3.9\;D:\PROGRAMS\Python\Python3.9\lib\site-packages
This helps to put desired directories at the beginning of the list, thus they are searched first and required libraries are found as it is supposed to work.

VS code cannot import local python modules

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!

python ModuleNotFoundError: No module named 'gplearn'

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.

ModuleNotFoundError: No module named zenpy on PyCharm (Mac)

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

ImportError: No module named 'com.android'

I'm writing a simple test for Android app and it fails while trying to connect my device with this log:
Traceback (most recent call last): File "D:/MonkeyRunnerTest/test/LaunchTest.py", line 3, in <module>
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice ImportError: No module named 'com'
I use Pycharm 2.7.3, Python 3.3.2, juthon-standalone-2.5.3. I've tried to launch my test project on Eclipse with PyDev and Intellij Idea with Python plug-in, but with the same result. Also I've added environment variable PYTHONPATH containing the path to monkeyrunner and jython source to my operation system (Windows 7), it didn't help.
Any suggestions for this issue?
You should only use monkeyrunner interpreter to run monkeyrunner scripts. Forget about python, jython, etc.
From you command line try:
monkeyrunner LaunchTest.py
and it will work.
You can find some instructions to use monkeyrunner with Eclipse+Pydev. See the updates at the bottom of the page.
Assuming you have the proper modules installed: They aren't in your system path. You can check your system path manually to see if the directory is there by doing
import sys
print sys.path
You can append to sys.path as you would any list, but it's probably better to modify it via your OS, rather than on the fly appending. (which is temporary, sys.path reverts to its original state after the end of the script in python)

Categories

Resources