Pycharm running Kivy applications - python

I'm running Pycharm 3.4.1 and i just downloaded the Kivy 1.8.0 for python 2.7 pack for windows.
http://kivy.org/#download
I chose the kivy interpreter as my python interpreter for the project:
C:\Python_Kivy_1.8.0\Python27\python.exe
The problem i'm having is that i can't get my Pycharm to run or recognize Kivy at all. There is no auto-completion when writing code and it can't execute via Pycharm. The only way i can execute the program is by running the python file with the kivy.bat file, and that is anoying to do every time.
When i'm trying to execute the code via pycharm i get the following error:
Traceback (most recent call last):
File "C:/Users/Victor/Dropbox/Private/filewatcher_gui/main.py", line 1, in <module>
import kivy
ImportError: No module named kivy
Process finished with exit code 1
I hope you can help me.

The kivy wiki has some pages on configuring for different ides, including pycharm.
You could also probably install in your existing installation using the (unofficial) prebuilt windows packages here. Make sure to get kivy's dependencies as well if you try this way.

Related

Messed up Python directories

I'm a complete beginner to coding, Python, and anything beyond user-level computing. I've been learning to code with Python and everything was fine until I tried to import a module outside of Python's Standard Library (pyglet).
pip install pyglet worked and now returns:
> Requirement already satisfied: pyglet in
c:\users\nick\appdata\local\programs\python\python38-32 (1.5.7)
Then I received an error message when running the module in PyCharm.
>C:\Users\Nick\venv\Scripts\python.exe C:/Users/Nick/PycharmProjects/learning1/leaning1.GUI.py
Traceback (most recent call last):
File "C:/Users/Nick/PycharmProjects/learning1/leaning1.GUI.py", line 1, in <module>
import pyglet
ModuleNotFoundError: No module named 'pyglet'
Process finished with exit code 1
I think there are a few possible sources for the issue.
I think I might be saving files in multiple directories, so PyCharm is unable to find what I need. If that's the problem please direct me to a resource on learning how to organize files on my computer (something very basic about directories because I know nothing).
I installed python via python.org, but then Microsoft Store was being opened automatically when I tried to check my python version in the command line. I also downloaded Python from Windows Store.
I tried to solve my problems by completely uninstalling PyCharm, Python (windows store), and Python (python.org). I also tried to delete all previous .py files. I don't think I located everything.
I messed with the interpreter settings in PyCharm.
What I really want is to just start over from a clean slate by scrubbing all Python things!
There are a few steps you should take to prevent this sort of issue:
Use a virtual environment: steps to create a virtual environment
Verify that PyCharm's project interpreter is the virtual environment you just created (in my example, the project is named cheetah and the virtual environment is also named cheetah):

Using a Python Package Outside of Anaconda

I wish to run a package, openquake; however, it was installed separately from Anaconda, which I am using to run python.
[centos modules]$ which python
~/anaconda2/bin/python
I have set openquake up and I believe it's installed correctly, however, when I try to run my script, I receive the following error:
[centos maxdist]$ python ../script.py
Traceback (most recent call last):
File "script.py", line 12, in <module>
from openquake.hazardlib.source import ComplexFaultSource
ImportError: No module named openquake.hazardlib.source
I was wondering if I need to add a line to my script for it to find the openquake module for it to run successfully? In general, what's the best way to run a python package that is installed outside of the main Anaconda python instance? I am trying to avoid having to re-install openquake for Anaconda, as I was having a little bit of difficulty with that work-around.
Thank you.
If both environments, anaconda and default python that you installed the library for have the same python version, then
import sys
sys.path.append(r'/path/to/package')
from openquake.hazardlib.source import ComplexFaultSource
Check if this works. If the package is compiled for different version, then there will be an error. Also, I would suggest you to use one environment and avoid doing this for the sake of simplicity.

Pyinstaller on Msys2 with pygobject

I have been building an application on Linux using python pygobject, and now I need to distribute it on Windows.
I first installed pygobject via msys2 (as per the official pygobject documentation)
Now, using msys2/mingw32, I can run my program typing
python3 main.py
But when I try to freeze it into a .exe with Pyinstaller, and try to run the produced .exe
If I Don't use --onefile, I get an import error on the _struct module (whereas "import _struct" works in python shell)
If I use --onefile, I get the Following error :
error:
lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-ani.dll could not be extracted!
fopen: No such file or directory
I’m using the devel version of Pyinstaller. I know next to nothing on Windows OS… does anyone know how to fix that error ?
It sounds like you were on the right path, unfortunately you ran in to a bug in PyInstaller. The good news is that the issue with the No module named '_struct' error is now fixed and released in version 3.6 and later. I would recommend using the --onedir mode of PyInstaller, you should be able to successfully package a GTK app for Windows.

Cannot import module with PyCharm, why?

PyCharm 2018.1.3 pro / Python 3.6.1 / Module: neo4j-driver 1.5.3
The strange thing is that if I trying to import neo4j.v1 using script editor in PyCharm and run it I'm getting error:
Traceback (most recent call last): File "C:/experiment/Cypher.py",
line 1, in from neo4j.v1 import GraphDatabase ModuleNotFoundError: No
module named 'neo4j'
Process finished with exit code 1
But this script works just fine if I call it using Windows PowerShell environment using simple command prompt:
> python C:/experiment/Cypher.py
So, I think that something is wrong with settings or with PyCharm. What should I do to solve this problem?
From pycharm,
goto settings -> project Interpreter
Click on + button on top right corner and you will get pop-up window of Available packages. Then search for neo4j python package.
Then click on Install package to install the package.
neo4j.v1 is not a default python module, it is not automatically installed when you install python.
To install neo4j.v1 Follow the instructions here.
Its possible to install it directly from pycharm, as other answers have pointed out, but its better to download from the official source to make sure all related dependencies and packages are properly installed.

Error Loading Python 3.4

My laptop is installed with Windows 7 64-bit operating system.
Prior to the installation of Python 3.4 using installation file "python-3.4.0.amd64.msi" (downloaded from https://www.python.org/downloads/release/python-340/), I have been using Python 2.7. However, I still need Python 2.7 for ABAQUS and hence need to retain it.
After I installed Python 3.4 and added its path to the environmental variables there was a conflict in calling "python" from command prompt. So I re-named python.exe in Python27 and Python34 folder as python27.exe and python34.exe, respectively. Also I added 27 and 34 as suffix to various other files in scripts folder in both version. I doubt if this is the best way to go forward in retaining two versions at the same time. So this is one question for which I would like an answer or a suitable reference.
But after installation of Python 3.4 I am not able to load python.exe, neither directly from folder nor command prompt. I get the following error:
Fatal Python error: Py_Initialize: unable to load the file system codec
Traceback (most recent call last):
File "C:\Python34\Lib\encodings\__init__.py", line 31, in <module>
ImportError: No module named 'codecs'
I am not able to uninstall the Python 3.4 from the control panel too. I get the following error when I attempt it:
I also tried removing the folder and installing the setup again. But still I get the same error.
I would be glad if some of the Python experts to help me resolve this problem.

Categories