I'm having a problem with Python when importing module openpyxl. I'm using Python 3.4 and have followed instructions and managed to install the module.
When I'm importing the module like this:
from openpyxl import workbook
It gives me the following error:
Traceback (most recent call last):
File "C:/Python34/test.py", line 1, in <module>
from openpyxl import workbook
ImportError: No module named 'openpyxl'
I installed the module following this step-by-step method:
I went in to the control panel - system and security - System - advanced system - system - enviroment variables - find path in the scroll bar and write in at the end where Python is installed. After this is done you can go in CMD and write python and it will find it.
In your modulepackage you downloaded there is a setup.py look up the directory of this.
Go to the CMD and write in cd followed by the directory.
Then write python setup.py and the setup will begin.
After the setup is done go in to the CMD and write python and then import "module name" if no error is shown the setup is finished.
Help me Stackoverflow, you're my only hope!
Related
I'm trying to create an embedded python for my project.
I downloaded the portable python 3.7.6
Copied the folders from my main python installation (Lib, Scripts, include, DLLs etc..)
Added them to the PTH file like so :
python37.zip
.
Lib
Lib/site-packages
Scripts
include
DLLs
doc
libs
Tools
tcl
# Uncomment to run site.main() automatically
#import site
and when I tested it, I tried to run a project with the following structure :
By running the command (using the embedded python):
G:\GitHub\VRoscopy\VRoscopy\Conversion\python\python.exe main.py
I get the following error :
> Traceback (most recent call last):
> File "mymain.py", line 1, in <module>
> import folder.module as m ModuleNotFoundError: No module named 'folder'
However, when I try running the system python everything works normally.
Hope anyone can help me, thanks
The problem was solved by adding the project files to the PTH file, and uncommenting the "import site" like follows :
python37.zip . ../invesalius
../invesalius/* # <----- added this line
Lib
Lib/site-packages
Scripts
include
DLLs
doc
libs
Tools
tcl
# Uncomment to run site.main() automatically
import site
I've created the following package tree:
/main_package
/child_package
version.py
where version.py contains a single string variable (VERSION)
Inside my script in child package I'm importing version.py by the following line:
from main_package.version import VERSION
While I'm running the code from PyCharm everything works great, however when I'm running the code via the command line I'm getting the following error message:
C:\Users\usr\PycharmProjects\project\main_package\child_package>python script.py
Traceback (most recent call last):
File "script.py", line 2, in <module>
from main_package.version import VERSION
ModuleNotFoundError: No module named 'main_package'
I've found in the internet that I might need to add my package to the python path, however it doesn't seems to work for me
PyCharm sets the Python Path at the root of the project (by default). To mimic this in a quick'n'dirty fashion, you just need to do this once in your shell session before invoking python whatever:
set PYTHONPATH=C:\Users\usr\PycharmProjects\project
The pythonic way is to have a setup.py file to install your project in the system (check python Minimal Structure):
from setuptools import setup
setup(name='main_package',
version='0.1',
description='main package',
license='MIT',
packages=['main_package'],
zip_safe=False)
Then you install it as follow:
python setup.py install for global installation
OR
python setup.py develop for local installation in editable mode
I am trying to run a Python script from Excel 2016 on Mac. When I run the code nothing happens, and the status bar in Excel gets stuck on "Running". I have checked the xlwings log file and I can see that the error is
Traceback (most recent call last):
File "", line 1, in
File "/Users/dano/Desktop/hello.py", line 3, in
import xlwings as xw
ImportError: No module named xlwings
However when I import xlwings from a Python shell it works fine, and I have also managed to write to the active workbook from the Python Shell using xlwings. Why does it say that there is no module named xlwingswhen I clearly have it installed?
I am using the simple hello.py example from the xlwings documentation:
import numpy as np
import xlwings as xw
def world():
wb = xw.Book.caller()
wb.sheets[0].range('A1').value = 'Hello World!'
The .py file and the excel file are located on my Desktop. I am running Python 3.6 and have installed xlwings using pip3.
xlwings takes the default Python installation as defined in your .bash_profile file, see the docs.
That is, you either need to include python3 in your PATH (given that you used pip3) or you need to set the Python interpreter via xlwings.
To set it in your .bash_profile, you would do something like:
export PATH="/path/to/python3/bin:$PATH"
I followed this guide: guide to create a startupfile which excecutes a python file on startup.
in step 2 it says I have to test the startupfile I just created and suddently my script says:
Traceback (most recent call last):
File "Display.py", line 1, in <module>
import pyowm
ImportError: No module named pyowm
the python file works perfect if I run it directly.
what I allready tried: run pip again to see if the lib was okay
check the /usr/local/lib/python3.4/dist-packages folder to see if it was there and it is.
I think this is a python issue and not a RaspberryPi issue thats why I uploaded it here.
runned by:
sh launcher.sh
inside is:
#!/bin/sh
# launcher.sh
# navigate to home directory, then to this directory, then execute python script, then back home
cd /
cd /home/pi/arduino/Python/Main/Master
sudo python Display.py
cd /
Simple fix: define the version of python which will be used. It used python 2.7. Yet the lib was for 3.4.
I need to test unity 3d app on mobile device (or emulator). I do not want to press on buttons using coordinates only, so I want to use Sikuli. I will describe steps that I have already done:
Downloaded and installed Sikuli v1.1.1
Installed java 32bit
Installed jython 2.7.0
jython added as interpreter in my project in pyCharm
sikulixapi is run
Copied Sikuli lib from appData to jython folder
Created Python file and added imports
And when I try to run project I receive this error:
D:\jython2.7.0\bin\jython.exe -Dpython.path=D:\python_projects\sikuli_test D:/python_projects/sikuli_test/test_sikuli.py
Tra**ceback (most recent call last):
File "D:/python_projects/sikuli_test/test_sikuli.py", line 1, in <module>
from sikuli import Region
File "D:\jython2.7.0\Lib\sikuli\__init__.py", line 5, in <module>
from org.sikuli.basics import Debug
ImportError: No module named sikuli
Process finished with exit code -1**
What am I doing wrong?
The following works for me:
import org.sikuli.script.SikulixForJython
before
from sikuli import *
In your jython project interpreter, set the environment variables path to where your sikuli jar is placed. That should fix it.
Also make sure to use this in your code
import org.sikuli.script.SikulixForJython
from sikuli import *