i'm a python noob - so maybe it is something simple - and please be patient ;-)
i'm stuck to get the cgal bindings running:
so i what i did so far:
installed/built cgal 5.1.1 and boost 1.74 using vcpkg
downloaded swig 4.0.2 and made the system path.
then i followed this: https://github.com/CGAL/cgal-swig-bindings/wiki/Installation
as a difference i did the cmake with the gui and then i compiled everything with visual studio.
there were some warnings, but no errors and it generated a folder with many *py, *pyd, *cxx files and a release folder with *lib and *exp files
when i now try test.py from the example folder i get:
C:\Dev\cgal-swig-bindings\examples\python>python test.py
Traceback (most recent call last):
File "test.py", line 2, in
from CGAL import CGAL_Triangulation_3
ModuleNotFoundError: No module named 'CGAL'
which somehow makes sense, as i never told python about the new stuff
so i copied test.py into the folder with the generated files folder with generated files
i get the same message...
i also tried pip install cgal-bindings. but it can't find CGAL (and other stuff...) altough i think i generated the path variable...
any hints on what i do wrong?
how can i get python to find the modules? (i also generated a system variable "PYTHONPATH" pointing at "C:\Dev\cgal-swig-bindings\build\CGAL-5.1.1_release\build-python\CGAL" - no difference)
Related
I'm unable to import pandas with import pandas as pd on replit.
I've already installed the package with pip install pandas and it can be seen in packages. I've successfully imported it to other projects on replit. Every time I try importing it into my code on this project, it gives me the following error:
Traceback (most recent call last):
File "main.py", line 1, in <module>
import pandas as pd
File "/home/runner/thing/venv/lib/python3.8/site-packages/pandas/__init__.py", line 16, in <module>
raise ImportError(
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "/home/runner/thing/venv/bin/python"
* The NumPy version is: "1.22.2"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: libz.so.1: cannot open shared object file: No such file or directory
You don't need to use pip to install packages on repl.it -- and in fact, you shouldn't! Using Nix derivations not only works better (as you're using their OS distro the way it's designed), but also keeps their storage costs low, by allowing packages to be used from a read-only, hash-addressed, shared store.
Binaries built for other distributions might assume that there will be libraries in /lib, /usr/lib, or the like, but that's not how NixOS works: Libraries will be in a path like /nix/store/<hash>-<packagename>-<version>/lib, and those paths get embedded into the executables that use those libraries.
The easiest thing to do here is to create a new bash repl, but to add a Python interpreter to it. (I suggest this instead of using a Python repl because the way they have their Python REPLs set up adds a bunch of extra tools that need to be reconfigured; a bash repl keeps it simple).
Create a new bash repl.
Click on the three-dots menu.
Select "Show Hidden Files".
Open the file named replit.nix
Edit the file by adding a Python interpreter with pandas, as follows:
{ pkgs }: {
deps = [
pkgs.bashInteractive
(pkgs.python38.withPackages (p: [p.pandas]))
];
}
...changing that to taste (as long as they're getting software from a channel that has binaries for Python 3.9 or 3.10, for example, you can change python38 to python39 or python310).
Click the "run" button
In the new shell that opens, run python, and see that you can import pandas without trouble.
If, after you add a Python file to your repl, you can also change the .replit hidden file to make it run that file automatically on startup. Note that on NixOS, you should use #!/usr/bin/env python as your shebang, as PATH lookups are essential.
I was trying to use urllib library but an error was shown
import urllib.request
Traceback (most recent call last):
File "E:\coding\python for everybody\third part\urllib.py", line 1, in <module>
import urllib.request
File "E:\coding\python for everybody\third part\urllib.py", line 1, in <module>
import urllib.request
ModuleNotFoundError: No module named 'urllib.request'; 'urllib' is not a package
process is terminated with return code 1.
I installed urllib3 using pip but, the package was installed in roaming/python/python39/site-packages.
While the path is set to C:\Program Files\Python\scripts. The folders python39 and python are located in different folders. Also, upon checking I found that package urllib was installed already C:\Program Files\Python\scripts.
I don't know how python is accessing the packages and how it determines the location as none of the packages are being imported (except random and other preinstalled packages).This problem has been very problematic not only this time but many times before.
PS: some time ago I deleted python (6 months approx) and at that time python was installed in roaming is this the result of that?
I am also using anaconda distribution, but the above code was being written in sublime text(Windows 10).
UPDATE: ISSUE WAS SOLVED BY CHANGING THE FILE NAME(LOOK IN THE COMMENTS)
If you are using code editors like VSCode, Notepad+++ and not PyCharm or other python IDE. I think you should check your path and make sure that you have same python version.
Your filename is the same as the library that causes confusion, please change the name as python will get looking at the working directory for import hence the error
I can't import modules of any kind. I know that I have the modules installed, and that they are inputted correctly, but it still does not work, and gives me this full error when trying to import numpy as np:
C:\Users\alecd\Desktop\Code\PYTHON\chess>C:/Users/alecd/AppData/Local/Microsoft/WindowsApps/python.exe c:/Users/alecd/Desktop/Code/PYTHON/chess/chess_board.py
Traceback (most recent call last):
File "c:/Users/alecd/Desktop/Code/PYTHON/chess/chess_board.py", line 3, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
I keep all my code in a lot of folders, and when I take the code out of the folders it works. However I don't want all of my code to be in one massive folder. I tried creating a new PYTHONPATH, which I believe will work but I would have to append all of my scripts every time, which would be pretty inefficient.
I actually had the same problem a week ago and found out that I installed 2 python envs at once. One was from original website(python.org) the other was from Microsoft Store. I kept installing modules on one and using another to run my code.
If you are using some kind of text editor(I was using Visual Studio Code) you need to select the right environment for compiler.
On Visual Studio Code you change compiler from left-bottom corner
VSCode
I'm having problems trying to use Metakit for Python on Windows. It always report this error:
Traceback (most recent call last):
File "<pyshell#86>", line 1, in <module>
import metakit
File "C:\Python27\lib\site-packages\metakit.py", line 22, in <module>
from Mk4py import *
ImportError: No module named Mk4py
I've already:
Downloaded metakit.py and Mk4py.dll from http://equi4.com/pub/mk/ (official release)
Copied metatkit.py to C:\Python27\lib\site-packages\
Copied Mk4py.dll to C:\Python27\DLLs\
I have installed Python 2.7.5 win32 version
Any idea to solve this problem?
I also had the same problem and couldn't get the system to work with the provided dlls. I also tried compiling metakit from source to make it work and installing it from an the official source via egg, which failed in the same way (as it compiles from source).
Using my older windows XP machine with visual studio 2002 I managed to build it from source and install it with just a minor change of the setup script (changing every instance of msvc60 to msvc70 in the setup script). However, copying those files to my windows 8 machine still failed, and even copying what appeared to be the changes were unsuccessful.
In the end I copied my entire python directory from the xp machine to the windows 8 machine and now it is working without issues.
Obviously i could provide my dlls but I doubt they would be any more successful than the provided ones.
My next step is to reduce my reliance on having to use metakit as it seems very poorly supported.
I want to run this library on Python 2.4 in Windows XP.
I installed the pygpgme-0.8.1.win32.exe file but got this:
>>> from pyme import core
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python24\Lib\site-packages\pyme\core.py", line 22, in ?
import pygpgme
File "C:\Python24\Lib\site-packages\pyme\pygpgme.py", line 7, in ?
import _pygpgme
ImportError: DLL load failed: The specified module could not be found.
And then this pop up comes up
---------------------------
python.exe - Unable To Locate Component
---------------------------
This application has failed to start because python25.dll was not found. Re-installing the application may fix this problem.
---------------------------
OK
Do I need to "compile" it for Python 2.4? How do I do that?
While the pygpgme project does not clearly document it, it's clear from the error message you got that their .win32.exe was indeed compiled for Python 2.5.
To compile their code for Python 2.4 (assuming they support that release!), download their sources, unpack them, open a command window, cd to the directory you unpacked their sources in, and run python setup.py install. This will probably not work unless you have the right Microsoft C compiler installed (MSVC 6.0 if I recall correctly).
It's no doubt going to be much less trouble to download, install and use Python 2.5 for Windows (it can perfectly well coexist with your current 2.4, no need to remove that). Is that a problem?