Python import error: 'No module named' - python

Just installed python, and am running into this error:
ImportError: No module named 'semanticnet'
here are my imports:
import semanticnet as sn
import sys
I've tried the solution on this site that suggests adding:
sys.path.append('C:\Python34')
after the 'import sys', but no luck.
Does anyone know what could be causing this issue?
Here is my full code: https://ideone.com/UHRI4S , running windows 10

You need to install that library, if you're on windows which it seems because of your "C://" first install setuptools.
https://pypi.python.org/pypi/setuptools
Using Windows 8 (which includes PowerShell 3) or earlier versions of Windows with PowerShell 3 installed, it’s possible to install with one simple Powershell command. Start up Powershell and paste this command:
(Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python -
You must start the Powershell with Administrative privileges or you may choose to install a user-local installation:
(Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | python - --user
If you have Python 3.3 or later, you can use the py command to install to different Python versions. For example, to install to Python 3.3 if you have Python 2.7 installed:
(Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | py -3 -
Once installed run as follows:
easy_install semanticnet

I think you don't have the module installed..
try pip install semanticnet on the Prompt Command first(I believe that you installed pip when you installed python), then when the installation is complete, just run python and try some ´import semanticnet` on the python command line...

Related

Installing and using RayLib in macOS 12.2.1 with Python 3.10

I am using a macOS 12.2.1 with Python 3.10 and I am trying to install Raylib Python CFFI 3.7 or higher but whenever I run the python3 -m pip install raylib command or the pip3 install raylib command but I keep getting the error below:
generating cffi module 'build/temp.macosx-10.9-universal2-3.10/raylib._raylib_cffi.c'
building 'raylib._raylib_cffi' extension
build/temp.macosx-10.9-universal2-3.10/raylib._raylib_cffi.c:570:14: fatal error: 'raylib.h' file not found
#include "raylib.h"
^~~~~~~~~~
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
I tried several things to solve this issue but no luck.
My macOS is using an Apple M1 Max chip and it looks like my macOS is having compilation issues with raylib.
If you have an M1 based Mac, you should create a Rosetta based terminal and work within that terminal by following these steps below [ONLY FOR macOS M1].
- Uninstall all the packages I previously had installed by executing python3 -m pip uninstall [package]
- Locate the Terminal application within the Utilities folder (Finder > Go menu > Utilities)
- Select Terminal.app and right-click on it, then choose “Duplicate”.
- Rename the duplicated Terminal app something obvious and distinct, like ‘Rosetta Terminal’.
- Now select the freshly renamed ‘Rosetta Terminal’ app and right-click and choose “Get Info” (or hit Command+i)
- Check the box for “Open using Rosetta”, then close the Get Info window.
- Run the “Rosetta Terminal” as usual, which will fully support Homebrew and other x86 command line apps.
- In the “Rosetta Terminal”, first ensure pip is upgraded python3 -m pip install --upgrade pip and then install raylib python3 -m pip install raylib
- Then you should be able to run your raylib based python game.

Install Shapely on Windows 10

I need your help for installing Shapely. The project where I work is on PyCharm and I need to install Shapely to compile the project:
from shapely.geometry import Point, Polygon, MultiPolygon, asShape
I've tried to install it from the interpretor (Settings > Interpretor > +) but it says me that
"WindowsError: [Error 126] The specified module could not be found".
So I decided to install it from the command line. I think that I've Python 2.7 and Python 3.5 installed on my Windows 10 laptop (Python --version returns Python 2.7.12 and python3 --version returns Python 3.5.2). I executed the following line:
import pip._internal; print(pip._internal.pep425tags.get_supported())
[('cp27', 'cp27m', 'win_amd64'), ('cp27', 'none', 'win_amd64'),...]
When I run from my Download folder (where the .whl is)
pip install Shapely-1.6.4.post1-cp27-cp27m-win_amd64.whl
I have the following message error:
Shapely-1.6.4.post1-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.
I have Python 2.7 (cp27) and my pip supports win_amd64. I don't really know what I can do now.
Try using conda install shapely, that helps avoid breaking your packages as well.

can't install numpy package in pycharm with latest pycharm and python 2.7

I installed Python 2.7, Pycharm 2017.3 and in pycharm in
settings > project interpreter > add package
I searched for numpy and installed the package but I get this error:
Error occured:
_configtest.c(7): error C2143: syntax error: missing ';' before 'volatile'
Proposed solution:
Try to run this command from the system terminal.
Make sure that you use the correct version of 'pip' installed for your Python interpreter located at
'C:\Users\Admin\PycharmProjects\second\venv\Scripts\python.exe'.
I tried by reinstalling everything but it didn't work.
I suppose that you are trying to install numpy on windows.
On windows, install this package could be quite complicated, so my suggestion is to use an unofficial installer for Numpy.
Here you can find the link with all unofficial installers, please search and open the Numpy link in the list.
Keep in mind to choose the right version, in this way:
cp = python version (i.e. cp27 = Pythonv2.7)
win_amd64 = x86_64 or win32 = windows 32 bit
Download it and then install it with the following command
pip install --user <numpy.whl>
for example, the following command install numpy v.1.13.3, for Python2.7 and for windowns 32:
pip install --user numpy‑1.13.3+mkl‑cp27‑cp27m‑win32.whl
Solved on Pycharm Pro and Comunity Edition
This is about near deprecation python 2.7, and dependencies requires older versions.
***File > Settings > project interpreter > Double Click to pip package >
Check Specify version to 9.0.1 (downgrade version to older). Click to install package.
***File > Settings > project interpreter > Add package (+) > Search and select matplotlib > Check Specify version to 1.5.3 (Downgrade to older). Click install package.
Regards. ;-)

I've installed Bottle for Python 2.7, but how to access ir from Python 3.2?

I have installed bottle on my Ubuntu Linux server using
sudo pip install bottle
and it is installed to: /usr/local/lib/python2.7/dist-packages
But I also have Python 3.2 installed on my system, and I want to access bottle from Python 3.2. Python 3.2 does not seem to recognise that bottle is installed.
What am I doing wrong?
You'd have to separately install it for Python 3.2 (with e.g. sudo pip-3.2 install bottle).
It's currently in python2.7/dist-packages, meaning that only 2.7 is going to load it. You could try to add that to your PYTHONPATH or similar, but that will very rarely work between Python 2 and 3 because the source files aren't quite compatible. (Any C extensions are also certainly not going to work, though bottle doesn't have any of those.)
Unfortunately, although that command works, it looks like the version of bottle in pypi isn't Python 3-compatible even when installed through pip-3.2:
In [1]: import bottle
File "/Library/Frameworks/Python.framework/Versions/3.2/bin/bottle.py", line 373
except re.error, e:
^
SyntaxError: invalid syntax
The homepage claims that it works with 3.x, but I got that error installing with both pip and easy_install. The latest development version, which is just a single file linked from the homepage, seems to work, though.
You are not doing anything wrong. Pip uses the /usr/bin/python by default and only installs there.
Unless you want to setup virtualenv-s, you probably best copy the current pip to pip3.2 and edit that to call python 3.2:
sudo -s -H
p=$(which pip)
cat $p | sed "1s|/usr/bin/python|$(which python3.2)|" > $p"3.2"
chmod 755 $p"3.2"
exit
You now have a pip3.2 that will install bottle so python3.2 can use it. If you get an error running pip3.2 about not finding pkg_resources look at No module named pkg_resources
I'll answer this myself. Turns out the latest release version of pip does not include pip-3.2. You need to download the development version and use that, which includes pip-3.2.
Just download it manually from offsite. It is just one file.
Place it into the lib/site-packages folder and give the file proper rights.

How to install python-dateutil on Windows?

I'm trying to convert some date/times to UTC, which I thought would be dead simple in Python - batteries included, right? Well, it would be simple except that Python (2.6) doesn't include any tzinfo classes. No problem, a quick search turns up python-dateutil which should do exactly what I need.
The problem is that I need to install it on Windows. I was able to upack the .tar.gz2 distribution using 7-zip, but now I'm left with a collection of files and no guidance on how to proceed. When I try to run setup.py I get the error "No module named setuptools".
If dateutil is missing install it via:
pip install python-dateutil
Or on Ubuntu:
sudo apt-get install python-dateutil
Why didn't someone tell me I was being a total noob? All I had to do was copy the dateutil directory to someplace in my Python path, and it was good to go.
Looks like the setup.py uses easy_install (i.e. setuptools). Just install the setuptools package and you will be all set.
To install setuptools in Python 2.6, see the answer to this question.
Install from the "Unofficial Windows Binaries for Python Extension Packages"
http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-dateutil
Pretty much has every package you would need.
It is a little tricky for people who is not used to command prompt. All you have
to do is open the directory where python is installed (C:\Python27 by default) and open the command prompt there (shift + right click and select open command window here) and then type :
python -m pip install python-dateutil
Hope that helps.
Using setup from distutils.core instead of setuptools in setup.py worked for me, too:
#from setuptools import setup
from distutils.core import setup
If you are offline and have untared the package, you can use command prompt.
Navigate to the untared folder and run:
python setup.py install
Just run command prompt as administrator and type this in.
easy_install python-dateutil
You could also change your PYTHONPATH:
$ python -c 'import dateutil'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named dateutil
$
$ PYTHONPATH="/usr/lib/python2.6/site-packages/python_dateutil-1.5-py2.6.egg":"${PYTHONPATH}"
$ export PYTHONPATH
$ python -c 'import dateutil'
$
Where /usr/lib/python2.6/site-packages/python_dateutil-1.5-py2.6.egg is the place dateutil was installed in my box (centos using sudo yum install python-dateutil15)
First confirm that you have in C:/python##/Lib/Site-packages/ a folder dateutil, perhaps you download it, you should already have pip,matplotlib, six##,,confirm you have installed dateutil by--- go to the cmd, cd /python, you should have a folder /Scripts. cd to Scripts, then type --pip install python-dateutil --
----This applies to windows 7 Ultimate 32bit, Python 3.4------
I followed several suggestions in this list without success. Finally got it installed on Windows using this method: I extracted the zip file and placed the folders under my python27 folder. In a DOS window, I navigated to the installed root folder from extracting the zip file (python-dateutil-2.6.0), then issued this command:
.\python setup.py install
Whammo-bammo it all worked.

Categories