I installed cx_Freeze using pip:
C:\Users\Sarah\Documents\PythonScripts>python -m pip install cx_Freeze --upgrade
Collecting cx_Freeze
Downloading cx_Freeze-5.0.2-cp36-cp36m-win_amd64.whl (162kB)
Installing collected packages: cx-Freeze
Successfully installed cx-Freeze-5.0.2
However, I get this error when I try to execute a script:
setup.py build
Traceback (most recent call last):
File "C:\Users\Sarah\Documents\PythonScripts\setup.py", line 9, in <module>
from cx_freeze import setup, Executable
ImportError: No module named cx_freeze
When I check the system path, I get all this information
print (sys.path)
['', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\spyder\\utils\\site', 'C:\\Users\\Sarah\\Documents\\PythonScripts', 'C:\\Users\\Sarah\\Anaconda3\\python36.zip', 'C:\\Users\\Sarah\\Anaconda3\\DLLs', 'C:\\Users\\Sarah\\Anaconda3\\lib', 'C:\\Users\\Sarah\\Anaconda3', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Sphinx-1.5.6-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\Pythonwin', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\setuptools-27.2.0-py3.6.egg', 'C:\\Users\\Sarah\\Anaconda3\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\Sarah\\.ipython']
I am assuming that somehow, the path to the cx_freeze module is lost in here somewhere. I would really appreciate some simple (novice user) ideas for how to go about fixing this.
I tried copying the folder cx-freeze to the PythonScripts folder but that didn't help.
I know why you are getting this error and I do not think it has anything to do with the file path.
Try:
from cx_Freeze import setup, Executable
in the place of
from cx_freeze import setup, Executable
in your setup.py script
and this error should fix (you had f not F).
Related
I'm trying to run the python script which has Xlwings for preparing excel in Windows 10 but I get the following error when I tried to run the script. I have already installed the Xlwings libraries.
Traceback (most recent call last):
File "C:\Users\xxxxx\Desktop\Python automation\PT.py", line 17, in <module>
import xlwings as xw
ModuleNotFoundError: No module named 'xlwings'
Can anyone please advise what's wrong with the xlwings. Please help
On your project folder, from your terminal, try doing this:
python -m venv venv
Windows - venv/Scripts/activate
Unix - source venv/Scripts/activate
You'll create a virtual environment. Then just pip install xlwings + other dependencies & re-run your project. Hope this helps
This is the first python library I am building. The folder structure looks like:
mylibrary
- build
- data
- docs
- environment.yml
- README.md
- license
- setup.py
- my library
- __init__.py
- Module1
- __init__.py
- module1_worklfow.py
- Module 2
- __init__.py
- module2_worklfow.py
On the init.py under "mylibrary" I have the statement from .Module1 import classfrommodule1workflow and from .Module2 import classfrommodule2workflow.
On the __init__ files that are inside the modules, I have from mylibrary.module1.module1_workflow import classfrommodule1workflow and the same for module2 init.
Now if I install the library through the conda command line with wheel, the library imports well. I am able to run in python from mylibrary import module1 but then if in the same command line I open a jupyter notebook, I am not able to import the library within jupyter. It says - no module named mylibrary.module1
I'm almost sure there's something wrong with my main init file, just can't figure out what it is.
EDIT: folder with files for MCVE here.
Steps on anaconda prompt:
cd folder_path
conda env create -f environment.yml
conda activate mylibrary
python setup.py bdist_wheel
pip install path_to_wheel
python
import mylibrary
import mylibrary.module1
quit()
This won't throw any errors, which is great! Then on the same command line:
jupyter notebook
then on the jupyter notebook:
import mylibrary
yields:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-8c582ad816fa> in <module>
----> 1 import mylibrary
ModuleNotFoundError: No module named 'mylibrary'
and
import mylibrary.module1
yields:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-64d831ac2965> in <module>
----> 1 import mylibrary.module1
ModuleNotFoundError: No module named 'mylibrary'
Here's an image for clarity:
Edit:
OK, I downloaded your code and it seems to be an issue with your setup.py after all. You forgot to add packages=find_packages(), to the argument list of setup, so the package you were installing was effectively empty. When import mylibrary was working for you when launching python from command line, it was probably because import also loads modules from current directory (try launching python from a different directory and check if it works).
By the way, you don't have to build a wheel if you just want to install from source. You can use pip install . or python setup.py install. Alternatively, for development purposes it's useful to do pip install --editable . or python setup.py develop.
Original answer:
Sounds like your package/library is OK but when you're launching jupyter notebook it's probably using a different interpreter. It should help to install jupyter in the conda environment. If it still doesn't work, you can try launching it with python -m jupyter notebook to ensure that you're using the same interpreter as for installing your package.
Python noob here. I've been trying to install pygame and pandas for a few hours now. Even with Conda I did not succeed. I have Python 3.8.5 installed.
I eventually tried through the terminal with these commands:
python -m pip install pygame==2.0.0.dev6
and
python -m pip install pandas
(this was a total guess by the way, but apparently it did something)
Results were succesfull:
Requirement already satisfied: pygame==2.0.0.dev6 in /opt/miniconda3/lib/python3.8/site-packages (2.0.0.dev6)
and
Successfully installed numpy-1.19.2 pandas-1.1.2 python-dateutil-2.8.1 pytz-2020.1
But, when I try to import either modules, I still get errors. Any ideas?
import pygame
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pygame
ModuleNotFoundError: No module named 'pygame'
import pandas
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
Do I need to move the modules to the script folder or something? Or what do I even move? Thanks!
Ok.. Got it thanks to #matt.. after succesfully installing pygame, find the environment in which pygame is installed by entering 'which python'.
In my case it returned:
/opt/miniconda3/bin/python
Now I needed to make sure the VS console was pointing at the same environment, by checking which python interpreter it was using and selecting the correct one. More info:
how to check and change environment in VS Code
I have used matlab, but I am only 2 weeks into Python. I downloaded anaconda 3.7 and am using spyder 4.1.3. I was following a youtube tutorial on python. I was doing well until the guy access the cmd prompt (I use Windows 10) from within his IDE.
I didn't know how to so I googled it and to do so I found on pypi.org that all I had to do was run pip install spyder-terminal in the cmd prompt. I tried this but at the end it said that I had a permissions error and to try the --user option. I copied and pasted the exact error and saw on git hub, to create an environment or run python -m pip install --user [INSERT PACKAGE NAME].
I don't really understand hat an environment is so I did the second --user way. I ran python -m pip install --user spyder terminal I got an error about a location not being in the path variable, so i just copied the file location that it referenced and copied it the the path. I then went to open up spyder 4.1.3 and i got the error
Traceback (most recent call last):
File "C:\Users\Aaron\anaconda3\lib\site-packages\qtpy\__init__.py", line 204, in
from PySide import __version__ as PYSIDE_VERSION # analysis:ignore
ModuleNotFoundError: No module named 'PySide'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Aaron\anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\Users\Aaron\anaconda3\lib\site-packages\spyder\app\start.py", line 201, in main
from spyder.app import mainwindow
File "C:\Users\Aaron\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 53, in
requirements.check_qt()
File "C:\Users\Aaron\anaconda3\lib\site-packages\spyder\requirements.py", line 41, in check_qt
import qtpy
File "C:\Users\Aaron\anaconda3\lib\site-packages\qtpy\__init__.py", line 210, in
raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found"
I tried opening it again and got the same error. I then tried uninstalling an dre-installing spyder in the anaconda navigator and got the same error. I tried removing the location I added to path and running "pip uninstall spyder-terminal", it said it was removed and I go the same error.
If possible, I am seeking specific steps in layman's terms, because all my knowledge thus far has come from the first 2 hours of a "cool things in python" type video.
I have installed leptonica and tesseract in $HOME/local and tesseract is working properly, then tesserocr python package with:
CPPFLAGS="-I/home/user/local/include /home/user/local/lib" pip install tesserocr
and when I want to invoke it I get this:
$ python3 extract.py
Traceback (most recent call last):
File "extract.py", line 4, in <module>
from tesserocr import PyTessBaseAPI, RIL, PyLTRResultIterator, iterate_level
ImportError: liblept.so.5: cannot open shared object file: No such file or directory
please help
As mentioned in my comment on the original post, the proper installation command should be:
CPPFLAGS="-I/home/user/local/include -L/home/user/local/lib" pip install tesserocr