I have installed both Python 3.7 and 3.9 in my Windows 10 using Microsoft Store, which put both python files in \Users\me\AppData\Local\Microsoft\WindowsApps:
The problem is that, when I try to create a virtual env with Python 3.9 using python3.9 -m venv venv, I get this error:
Could not import runpy module
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 14, in <module>
import importlib.machinery # importlib first so we can test #15386 via -m
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 51, in <module>
_w_long = _bootstrap_external._w_long
AttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long'
I read that this happens because it is trying to use pip3.7, but I can't find how to instruct python to use pip3.9.
Unset the $PYTHONPATH environment variable. That is what is causing python3.9 to incorrectly find code inside Python-3.7.
set PYTHONPATH=
python3.9 -m venv .venv
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
I'm trying to build pyslam project, and the install.sh file was provided. But when I executed install.sh, the main.py didn't work.
https://github.com/luigifreda/pyslam#install-pyslam-under-ubuntu-2004
Full Installation
In order to run main_slam.py with venv, get in the root of this repository and run the following command:
$ . install_all_venv.sh
N.B.: do not forget the dot! (without '/' !)
This will compile the required thirdparty packages and will also activate the created pyslam environment. Now, from the same terminal, you can run:
$ python3 -O main_slam.py
The result was
(pyslam) (base) ict-526#ict526-MS-7D32:~/pyslam$ python3 -O main_slam.py
Traceback (most recent call last):
File "/home/ict-526/pyslam/main_slam.py", line 27, in <module>
from config import Config
File "/home/ict-526/pyslam/config.py", line 27, in <module>
import yaml
ModuleNotFoundError: No module named 'yaml'
I think the packages didn't install in the venv (pyslam). How can I fix this situation?
My environment is ubuntu20.04, and python 3.9.7.
According to the installaion instruction, python 3.6.9 was required. After install_all_venv.sh, the pyslam venv support python 3.9.7...
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
After updating to python3.7, conda no longer works:
DN0a22955d:~ harryemeric$ conda list
\Traceback (most recent call last):
File "/Users/harryemeric/anaconda3/bin/conda", line 12, in <module>
from conda.cli import main
ModuleNotFoundError: No module named 'conda'
This is my bash profile, I tried adding the address for 3.7 but I don't know if this is right, or really what this does. Any help much appreciated!
source ~/.bashrc
# Setting PATH for Python 3.4
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.4/bin:${PATH}"
export PATH
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
# added by Anaconda3 5.0.0 installer
export PATH="/Users/harryemeric/anaconda3/bin:$PATH"
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
I have installed Spyder3.2.1 in the current version of Miniconda3 on my Debian v-9.1.0 64 bit Linux platform. Spyder is performing well, but I am having difficulty installing the RDKit.
I followed the directions in the RDKit_Docs_current.pdf:
How to install RDKit with Conda
Creating a new conda environment with the RDKit installed using these
packages requires one single command similar to the following:
$ conda create -c rdkit -n my-rdkit-env rdkit
Finally, the new environment must be activated, so that the
corresponding python interpreter becomes available in the same shell:
$ source activate my-rdkit-env
There were no warning or error messages during the installation, but when I attempt running a simple Python script:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 15 11:41:24 2017
#author: comp
"""
from __future__ import print_function
from rdkit import Chem
m = Chem.MolFromSmiles('Cc1ccccc1')
m
I get:
IPython 6.1.0 -- An enhanced Interactive Python.
runfile('/home/comp/Apps/Python/untitled0.py',
wdir='/home/comp/Apps/Python')
Traceback (most recent call last):
File "<ipython-input-1-3842c59475d8>", line 1, in <module>
runfile('/home/comp/Apps/Python/untitled0.py',
wdir='/home/comp/Apps/Python')
File "/home/comp/Apps/miniconda3/lib/python3.6/site-
packages/spyder/utils/site/sitecustomize.py", line 688, in runfile
execfile(filename, namespace)
File "/home/comp/Apps/miniconda3/lib/python3.6/site-
packages/spyder/utils/site/sitecustomize.py", line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/comp/Apps/Python/untitled0.py", line 10, in <module>
from rdkit import Chem
ModuleNotFoundError: No module named 'rdkit'
RDKit is installed in ~/miniconda3/envs/mr-rdkit-env
Unfortunately, I have no clue as to what the problem(s) may be, assistance will be much appreciated.
Thanks in advance.
If you are using PyCharm try to install RDKit package in File > Settings > Project Interpreter > + , then seach for RDkit to install and use the Python Interpreter where the RDKit is installed or you can reference your ~/miniconda3/envs/mr-rdkit-env/python.exe on your Python Interpreter
switch your currrent python edition to python2.7,you can create a enviroment:conda create -n my_env_name python=2.7